[R] Matching a vector with a matrix row

From: Luis Felipe Parra <felipe.parra_at_quantil.com.co>
Date: Fri, 22 Apr 2011 11:56:14 +0800


Hello I am trying to compare a vector with a Matrix's rows.The vector has the same length as the number of columns of the matrix, and I would like to find the row numbers where the matrix's row us the same as the given vector. What I am doing at the moment is using apply as follows:

apply(Matrix,1,function(x)all(x%in%LHS))

but this isn't too fast actually. I would like to know if any body knows an efficient (fast) way of doing this? The matrix contains stings (not numbers).

Thank you

Felipe Parra

        [[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 Fri 22 Apr 2011 - 03:58:43 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 Fri 22 Apr 2011 - 06:00:31 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