I have two data frames that I believe are identical, yet checking them with identical() fails. Each data frame has two columns named 'pk' and 'newv_f13__bool'. As shown below, the columns of the data frames are identical, according to the identical() function, yet the data frames themselves are not. How can this be? Browse[1]> identical(shft$pk, shft_mat$pk) [1] TRUE Browse[1]> identical(shft$newv_f13__bool, shft_mat$newv_f13__bool) [1] TRUE Browse[1]> identical(shft, shft_mat) [1] FALSE I have attached a file in which the two data frames are saved (using the save() function).
On Apr 6, 2014, at 7:00 AM, Rguy wrote:> I have two data frames that I believe are identical, yet checking > them with > identical() fails. > > Each data frame has two columns named 'pk' and 'newv_f13__bool'. As > shown > below, the columns of the data frames are identical, according to the > identical() function, yet the data frames themselves are not. How > can this > be? > > Browse[1]> identical(shft$pk, shft_mat$pk) > [1] TRUE > Browse[1]> identical(shft$newv_f13__bool, shft_mat$newv_f13__bool) > [1] TRUE > Browse[1]> identical(shft, shft_mat) > [1] FALSEIt could be as simple as having a different column order: > df1 <- df4 > identical(df1,df4) [1] TRUE > df1[] <- df1[rev(names(df1))] > identical(df1,df4) [1] FALSE> > I have attached a file in which the two data frames are saved (using > the > save() function).No attachment. Probably not a text file. Read the general instructions page more carefully. -- David Winsemius, MD Alameda, CA, USA
On 07/04/14 02:00, Rguy wrote:> I have two data frames that I believe are identical, yet checking them with > identical() fails. > > Each data frame has two columns named 'pk' and 'newv_f13__bool'. As shown > below, the columns of the data frames are identical, according to the > identical() function, yet the data frames themselves are not. How can this > be? > > Browse[1]> identical(shft$pk, shft_mat$pk) > [1] TRUE > Browse[1]> identical(shft$newv_f13__bool, shft_mat$newv_f13__bool) > [1] TRUE > Browse[1]> identical(shft, shft_mat) > [1] FALSE > > I have attached a file in which the two data frames are saved (using the > save() function).Attachment did not come through. What does all.equal() say about your two data frames? cheers, Rolf Turner