Re: [R] searching for specific row in matrix

From: Esmail Bonakdarian <>
Date: Wed, 11 Jun 2008 09:48:41 -0400

Dimitris Rizopoulos wrote:
> try this:
> match.pat <- function (mat, target, nomatch = -1) {
> f1 <-"paste", c(, sep = "\r"))
> f2 <- paste(target, collapse = "\r")
> ind <- f1 %in% f2
> if (any(ind)) which(ind)[1] else nomatch
> }

Thanks! More R for me to sink my teeth in :-) My own solution doesn't seem to work quite correctly as I found out from some further testing .. so the solutions posted here are much appreciated!

Esmail mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Wed 11 Jun 2008 - 15:36:44 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 Wed 11 Jun 2008 - 16:30:41 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive