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

From: Waverley <waverley.paloalto_at_gmail.com>
Date: Sun, 09 Mar 2008 16:22:30 -0700


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

R-help_at_r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Sun 09 Mar 2008 - 23:26:16 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 10 Mar 2008 - 02:30:21 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive