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
When first learning subsetting, a common mistake is to use x[which(y)] instead of x[y]. Here the which() achieves nothing: it switches from logical to integer subsetting, but the result will be exactly the same.
I'm not sure I agree; if length(which(y)) << length(y) there can be obvious performance benefits:
x <- runif(1e8)
x[1] <- NA;
system.time(x[is.na(x)])
system.time(x[which(is.na(x))])
The text was updated successfully, but these errors were encountered:
I'm not sure I agree; if
length(which(y)) << length(y)
there can be obvious performance benefits:The text was updated successfully, but these errors were encountered: