[R] Extracting only the non-repeated rows of matrices

dreamworx Andy_woolston at hotmail.com
Mon Jul 6 13:39:22 CEST 2009


I have 2 matrices. One which contains a complete set of row combinations.
Another which contains a subset of the first. What I would like to extract
is the rows which are in the first but not repeated in the second. For
instance if the following were my two matrices,

A
       [,1] [,2] [,3] [,4]
  [1,]    1    2    3    4
  [2,]    1    2    3    5
  [3,]    1    2    3    6
  [4,]    1    2    3    7
  [5,]    1    2    3    8
  [6,]    1    2    3    9


B
       [,1] [,2] [,3] [,4]
  [1,]    1    2    3    4
  [2,]    1    2    3    5
  [3,]    1    2    3    6
  [4,]    1    2    3    9


I would like to extract the following,

       [,1] [,2] [,3] [,4]
  [1,]    1    2    3    7
  [2,]    1    2    3    8

I would like to know if there is a simple solution to this problem? If I
added the matrices and used the unique function, could I track which rows
have been deleted? Otherwise, I can only think of performing a loop with an
if statement.
-- 
View this message in context: http://www.nabble.com/Extracting-only-the-non-repeated-rows-of-matrices-tp24353933p24353933.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list