Re: [R] finding rows in a matrix that match a vector

2012-02-02 Thread Uwe Ligges
On 28.01.2012 05:43, Melissa Patrician wrote: Hi, Please excuse my inexperience, but I am just learning R (this is my very first day programming in R) and having a really hard time figuring out how to do the following: I have a matrix that is 1000 row by 6 columns (named 'table.combos') and

Re: [R] finding rows in a matrix that match a vector

2012-01-28 Thread Florent D.
Try this: mine - 1:6 table.combos - matrix(data = 1:12, nrow = 10, ncol = 6, byrow) row.is.a.match - apply(table.combos, 1, identical, mine) match.idx - which(row.is.a.match) total.matches - sum(row.is.a.match) On Sat, Jan 28, 2012 at 2:10 AM, Jason J. Pitt pit...@uchicago.edu wrote: Hi

[R] finding rows in a matrix that match a vector

2012-01-27 Thread Melissa Patrician
Hi, Please excuse my inexperience, but I am just learning R (this is my very first day programming in R) and having a really hard time figuring out how to do the following: I have a matrix that is 1000 row by 6 columns (named 'table.combos') and a 1 row by 6 column vector (named 'mine'). I

[R] finding rows in a matrix that match a vector

2012-01-27 Thread Melrose2012
Hi, Please excuse my ignorance, but I am just learning R (this is my very first day programming in R) and having a really hard time figuring out how to do the following: I have a matrix that is 1000 row by 6 columns (named 'table.combos') and a 1 row by 6 column vector (named 'mine'). I want to

Re: [R] finding rows in a matrix that match a vector

2012-01-27 Thread Jason J. Pitt
Hi Melissa, Well, assuming you know the length of the length of the row in the matrix and vector are the same... if you need a quick fix you could use mine - 1:6 table.combos - matrix(data = 1:12, nrow = 2, ncol = 6, byrow = T) sum(mine == table.combos[1, ]) == length(mine) # returns TRUE