Checking if to DataFrames are identical
0
0
Entering edit mode
maltethodberg ▴ 180
@maltethodberg-9690
Last seen 13 days ago
Denmark

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?

S4Vectors DataFrame • 972 views
ADD COMMENT
1
Entering edit mode

Could be a lot of things. all.equal() is a good way to figure out which one(s).

ADD REPLY

Login before adding your answer.

Traffic: 816 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6