Skip to content
Prev 334100 / 398513 Next

Need help figuring out sapply (and similar functions) with multiple parameter user defined function

Hi

The warning is due to fact that "if" takes only single scalar value not an entire vector.

Maybe you shall explain more clearly what result do you expect.

I bet that there is vectorised solution to your problem but I am lost in your ifs and cannot follow what shall be the output.

Please use 

dput(head(df))

when showing input data and clearly describe intended result.

Regards
Petr