I just saw what seemed like a perfectly good question that was deleted, and since, like the original questionnaire, I could not find a duplicate, I send the message again.
Suppose I have a simple matrix ("m") that I want to index using another logical matrix ("i"), keeping the original matrix structure intact. Something like that:
# original matrix m <- matrix(1:12, nrow = 3, ncol = 4)
Using m[i] returns a vector, not a matrix. What is the right way to achieve this?
r indexing na
42-
source share