Hi everyone:

 

  I have a kinda easy question but i do not know how to solve that in a simple 
way.

  I want to compare the rows of two matrices. 

  

  col1 <- c(1,2,3,4,5,6)

  col2 <- c(6,5,4,3,2,1)

  m <-  cbind(col1, col2)

  

  col3 <- c(1,3,2,6)

  col4 <- c(6,3,5,1)

  n <- cbind(col3, col4)

 

  In matrix n,  for example the first row is (1,6), it is also some row in 
matrix m, i want the code results "TRUE".  then for the 2nd row (3,3), it 
should be FALSE. 

  So in this case it should be (TRUE, FALSE, TRUE, TRUE)

 

  I tried %in% or is.element for a row in n and matrix m, but it does not work. 

  I think I can also write two loops to compare the rows of m and n one by one, 
but it takes a long time to run.

  Could anyone tell me how to solve this?

 

 

Thank you very much!!

 
                                          
        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to