regarding matrix comparison in R

前端 未结 1 702
挽巷
挽巷 2020-12-20 16:44

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?

1条回答
  •  长情又很酷
    2020-12-20 17:16

    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) )

    0 讨论(0)
提交回复
热议问题