0

I am trying to compare between 2 values, both numeric and identical, but still get FALSE, any one know what is the reason?

 class(merged_01_11$X1_01)
#[1] "numeric"
 class(merged_01_11$X1_11)
#[1] "numeric"
 merged_01_11$X1_11[1]
#[1] 8291870
 merged_01_11$X1_01[1]
#[1] 8291870
 identical(merged_01_11$X1_11[1], merged_01_11$X1_01[1])
#[1] FALSE
user20650
  • 24,654
  • 5
  • 56
  • 91
Rami Krispin
  • 79
  • 1
  • 6
  • 4
    May be one of them is not equal to `8291870`. You can check [here](http://stackoverflow.com/questions/9508518/why-are-these-numbers-not-equal) – akrun Jan 10 '16 at 16:36
  • 3
    You probably want to use `all.equal`. – Roland Jan 10 '16 at 16:37
  • 1
    Thanks! it works now with : isTRUE(all.equal(merged_01_11$X1_11[1], merged_01_11$X1_01[1])) [1] TRUE – Rami Krispin Jan 10 '16 at 16:43
  • @RamiKrispin It would be good to understand why `identical` isn't working, can you put in minimal data to reproduce, perhaps just one line from each data frame ? – steveb Jan 10 '16 at 18:24
  • @steveb; its due to floating point differences - see the link in Akrun's comment. – user20650 Jan 10 '16 at 18:43

0 Answers0