On Sat, Apr 23, 2011 at 08:56:33AM +0800, Luis Felipe Parra wrote: > Hello Niels, I am trying to find the rows in Matrix which contain all of the > elements in LHS.
This sounds like you want an equivalent of all(LHS %in% x) However, in your original post, you used all(x %in% LHS) What is correct? If the equality of x and LHS should be tested, then try setequal(x, LHS) If the rows may contain repeated elements and the number of repetitions should also match, then try identical(sort(x), sort(LHS)) with a precomputed sort(LHS) for efficiency. If the number of the different character values in the whole matrix is not too large, then efficiency of the comparison may be improved, if the matrix is converted to a matrix consisting of integer codes instead of the original character values. See ?factor for the meaning of "integer codes". After this conversion, the comparison can be done by comparing integers instead of character values, which is faster. Hope this helps. Petr Savicky. ______________________________________________ R-help@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.