[R] how to get the rows that satisfy a specific condition
Fix Ace
acefix at rocketmail.com
Sat Sep 27 00:15:14 CEST 2014
Hello, there,
I wonder if there is an easier way that I would only get the rows that satisfies some condition. For example:I have the following matrix, and I would like to output only the 3rd row and 4th row, since only these two rows contain the numbers greater than 11
> a
[,1] [,2] [,3] [,4] [,5]
[1,] 1 5 9 13 17
[2,] 2 6 10 14 18
[3,] 3 7 11 15 19
[4,] 4 8 12 16 20
> a>11
[,1] [,2] [,3] [,4] [,5]
[1,] FALSE FALSE FALSE TRUE TRUE
[2,] FALSE FALSE FALSE TRUE TRUE
[3,] FALSE FALSE FALSE TRUE TRUE
[4,] FALSE FALSE TRUE TRUE TRUE
I have tried to use a[a>11, ] and it did not work.
Thanks a lot for the help:)
[[alternative HTML version deleted]]
More information about the R-help
mailing list