[R] matching rows in matrices

2009-07-02 Thread dreamworx
I have a matrix such as this, [,1] [,2] [,3] [1,]112 [2,]255 and a larger matrix such as this, a b [1,] 1 5 [2,] 2 5 [3,] 4 9 [4,] 5 8 [5,] 7 8 [6,] 7 10 [7,] 9 10 what I want to do is check the number of times the columns in the first matrix appear as

Re: [R] matching rows in matrices

2009-07-02 Thread Gabor Grothendieck
If A and B are first and second matrix respectively then try: rowSums(inner(A, t(B), identical)) where the generalized inner product, inner, is defined in this post: http://tolstoy.newcastle.edu.au/R/e4/help/08/08/19562.html On Thu, Jul 2, 2009 at 8:27 AM, dreamworxandy_wools...@hotmail.com

Re: [R] matching rows in matrices

2009-07-02 Thread Marc Schwartz
On Jul 2, 2009, at 7:27 AM, dreamworx wrote: I have a matrix such as this, [,1] [,2] [,3] [1,]112 [2,]255 and a larger matrix such as this, a b [1,] 1 5 [2,] 2 5 [3,] 4 9 [4,] 5 8 [5,] 7 8 [6,] 7 10 [7,] 9 10 what I want to do is check the number of

Re: [R] matching rows in matrices

2009-07-02 Thread Ravi Varadhan
Cc: r-help@r-project.org Subject: Re: [R] matching rows in matrices On Jul 2, 2009, at 7:27 AM, dreamworx wrote: I have a matrix such as this, [,1] [,2] [,3] [1,]112 [2,]255 and a larger matrix such as this, a b [1,] 1 5 [2,] 2 5 [3,] 4 9 [4,] 5 8