[R] Matrix manipulation

From: Joseph N. Paulson <josephpaulson_at_gmail.com>
Date: Sat, 02 Apr 2011 01:08:45 -0400


Hi all!

I have a vector, let's say for example int <- sample(1:20,10); for now:

now I have a matrix...
M = m x n
where the first column is a "feature" column and most likely shares at least one of the int (interesting) numbers.

I want to extract the rows where int[] = M[,1]

I thought:
rownames(int)<-int;
rownames(M)<-M[,1];

M[rownames(int),] would work, but it doesn't... (I assume because I have rownames(int) that are not found in M[,1]. Neither does, rownames(M)==rownames(int)...

Any help would be greatly appreciated!

Thank you!

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Sat 02 Apr 2011 - 05:20:40 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 Sat 02 Apr 2011 - 08:00:26 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