R will give you this warning if you attempt to pass a multi-element vector to a function which can operate on only one logical element.
This is most commonly thrown when you pass a multi-element vector to a single variable function such as if () or else(). Since these functions can only address a single element at a time, this warning will be shown.
I will note that R is at least attempting to handle the exception and keep moving forward with the program, rather than the more traditional “halt and catch fire” behavior which base R prefers to engage in.
You will need to rewrite the offending function so it can operate against a vector rather than a single value. Take look at either sapply() or ifelse(). The details of a solution will need to be based on the specifics of your function…
Error: the condition has length > 1 and only the first element will be used.