0

I have two data frames, each with a column of integer64 type. When I compare the data frames using all.equal(), I get TRUE, even when the values are wildly different:

library(bit64)
original <- data.frame("a" = as.integer64(c(2, 3, 6)), "b" = c("second", "data", "column"))
new <- data.frame("a" = as.integer64(c(2, 30000, 6000001)), "b" = c("second", "data", "column"))
all.equal(original, new)
# TRUE

I know that all.equal() can accept non-exact matching (e.g. with rounding) and that for scrupulously exact matching identical() is the safer choice, but why does all.equal() say that these two data frames are the same? Is there a way to get a comparison of the data frames with the useful details of all.equal() but while rejecting these two tables as equivalent?

user3757897
  • 316
  • 2
  • 13

1 Answers1

2

I cannot reproduce that:

R> library(bit64)
R> original <- data.frame(a=as.integer64(c(2, 3, 6)), 
+                         b=c("second", "data", "column"))
R> new <- data.frame(a=as.integer64(c(2, 30000, 6000001)), 
+                    b=c("second", "data", "column"))
R> all.equal(original, new)
[1] "Component “a”: Mean relative difference: 669999"
R> 

What version of bit64 are you running?

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • 1
    That was it, thank you! I had version 0.9.7 for some bizarre reason - I've updated to 4.0.5 and now I get the expected 'Component “a”: Mean relative difference: 669999.1' – user3757897 Sep 09 '20 at 14:35
  • I think it was in fact a bug in the older version that is now squashed. – Dirk Eddelbuettel Sep 09 '20 at 14:54