x <- seq(0.1,10,0.1)
y <- if (x < 5) 1 else 2
This gives a warning (or error since R version 4.2.0) that the condition has length > 1.
I would want the if to operate on every single case instead of operating on the whole vector.
What do I have to change?
1 Answer