Entering edit mode
I'm trying to check if to DataFrame objects are identical.
My case in point:
> d1
DataFrame with 3 rows and 4 columns
Name BigWigPlus BigWigMinus totalTags
<character> <character> <character> <numeric> C547 C547 mm9.C547.plus.bw mm9.C547.minus.bw 12436172 C548 C548 mm9.C548.plus.bw mm9.C548.minus.bw 12277807 C549 C549 mm9.C549.plus.bw mm9.C549.minus.bw 14477276
> d2
DataFrame with 3 rows and 4 columns
Name BigWigPlus BigWigMinus totalTags
<character> <character> <character> <numeric> C547 C547 mm9.C547.plus.bw mm9.C547.minus.bw 12436172 C548 C548 mm9.C548.plus.bw mm9.C548.minus.bw 12277807 C549 C549 mm9.C549.plus.bw mm9.C549.minus.bw 14477276
These two look identical but:
> identical(d1, d2)
[1] FALSE
Coercing to a data.frame, they are identical:
> identical(as.data.frame(d1), as.data.frame(d2))
[1] TRUE
All individual columns are also identical:
> identical(d1$Name, d2$Name)
[1] TRUE
> identical(d1$BigWigPlus, d2$BigWigPlus)
[1] TRUE
> identical(d1$BigWigMinus, d2$BigWigMinus)
[1] TRUE
> identical(d1$totalTags, d2$totalTags)
[1] TRUE
The DataFrames haven't got anything store in the metadata slot.
What could explain this behaviour? What's the preferred way to compare DataFrame objects in this fashion?
Could be a lot of things.
all.equal()
is a good way to figure out which one(s).