try this:
> set.seed(1)
> mat <- matrix(sample(1:2, 30, TRUE), ncol=3) # test data
> pat <- c(1, 2, 1) # find matches
> mat
[,1] [,2] [,3]
[1,] 1 1 2
[2,] 1 1 1
[3,] 2 2 2
[4,] 2 1 1
[5,] 1 2 1
[6,] 2 1 1
[7,] 2 2 1
[8,] 2 2 1
[9,] 2 1 2
[10,] 1 2 1> which(apply(mat, 1, function(.row) all(.row == pat)))
[1] 5 10>
>
On Wed, Sep 16, 2009 at 7:37 PM, Ubirajara <jaradascavernas at gmail.com>
wrote:> Hello.
> ? ? ? ?I have a three column matrix named x, each one with a numeric value.
> Given a three element vector, is there any function that finds the row
where
> the values match?
>
> ?Thanks in advance.
>
> ? ? ? ? ? ? ? Ubirajara Albeton
>
> ______________________________________________
> 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.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?