Your question has been answered by Achim and Peter Dalgaard (at least).
Just a note:
Using a[which(logic)] looks like a clumsy and inefficient way of writing a[ logic ]
and I think you shouldn't propagate its use ...
What then is the recommended way of treating an NA in the logical subset as a FALSE? (Or were you just talking about the given example, which didn't have this issue. However, you admonition seemed more general.)
As in: > x <- 1:4 > y <- c(1,2,NA,4) > x[y %% 2 == 0] [1] 2 NA 4 > x[which(y %% 2 == 0)] [1] 2 4 >
Sometimes one might want the first result, but more usually, I want the second, and using which() seems a convenient way to get it.
-- Tony Plate
______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help