[R] question about matrix one column values matching a vector of values

Waverley waverley.paloalto at gmail.com
Mon Mar 10 00:22:30 CET 2008


Hi,

I have a matrix
a = matrix (1:16, 4, 4)
b = c (2,3)

I want to find out which rows of a, where a[,1] equals any values of b?

I know that if b is only one value, e.g, b=2, then what I want is a[a[,1] == 2,]

But what about if it is not one value but a vector of values?

Thanks much in advance.

-- 
Waverley @ Palo Alto



More information about the R-help mailing list