Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

regarding matrix comparison in R

Tags:

r

Currently, I have two matrixes, and want to compare it and see whether they are exactly equivalent. In R, is there any function to do that?

like image 631
user288609 Avatar asked Aug 01 '12 21:08

user288609


1 Answers

As stated above start with ?all.equal or ?identical. If you then find that your matrices are unequal, you may want to compare them column by column. This might do the trick:

mapply(as.data.frame(m1),as.data.frame(m2),FUN=function(v1,v2) all(v1==v2) )

like image 100
Michael Avatar answered Oct 03 '22 04:10

Michael