You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to one example in the function documentation
# case_when() evaluates all RHS expressions, and then constructs its# result by extracting the selected (via the LHS expressions) parts.# In particular NaN are produced in this case:y<- seq(-2, 2, by=.5)
case_when(
y>=0~ sqrt(y),
TRUE~y
)
Wouldn't it be better to only evaluate the RHS for the instances where the LHS is TRUE and then paste these evaluations together?
If there are five cases evenly distributed across the vector, this means five times more computations. Yes, vectorization is fast, but it's faster to not do computations one is not interested in anyway.
The text was updated successfully, but these errors were encountered:
According to one example in the function documentation
Wouldn't it be better to only evaluate the RHS for the instances where the LHS is TRUE and then paste these evaluations together?
If there are five cases evenly distributed across the vector, this means five times more computations. Yes, vectorization is fast, but it's faster to not do computations one is not interested in anyway.
The text was updated successfully, but these errors were encountered: