Comparing two data frames

I have two data frames df1 and df2 , now I am comparing two dataframes , dataframes are so big can't share reproducible example but getting error while executing.

objective is to list out the variables or records which are different from another data frame. I am trying like below but getting error .

both the data frame were just read and then compare

New <- as.data.frame(df1)
old <- as.data.frame(df2)
compare_DF <- dataCompareR::rCompare(df1,df2)

Error in value[3L] :
ERROR:Error in as.data.frame.default(doa): cannot coerce class ‘"function"’ to a data.frame

any help...??

My suggestion... compare some smaller datatframes first, before comparing these too 'big to share' ones.

Also you should say what packages you rely on.

First compare their columns are same by the great function in janitor package.
janitor::compare_df_cols(df1,df2)

If the columns are identical make sure they are in the same order and then convert the data.frames to data.table (I always work in data.tables as they are much faster than classical R data.frames)

library(data.table)
setDT(df1); setDT(df2)
fsetdiff(df1,df2)

The above will give you rows in df1 that are not in df2.
To see the other way round run:
fsetdiff(df2,df1)

See if this fulfils the objective. If not let me know.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.