I need to compare two dataframes that explain the same things, but they came from different ways to obtain them.
So I need to obtain a df where every single value is compared to the respective on the other df, and give to me TRUE if values are identical, FALSE if they aren't.
I write an example just for better explain:
df1
> 1 2 3
> 1 AT GC CC
> 2 AG GC CT
> 3 GG TT <NA>
df2
> 1 2 3
> 1 AT <NA> GG
> 2 AG GC CG
> 3 GG TT AA
result
> 1 2 3
> 1 TRUE <NA> FALSE
> 2 TRUE TRUE FALSE
> 3 TRUE TRUE <NA>
I've seen here a result
Comparing two similar dataframes and finding different values between them
but in my df doesn't work if one of the df has an NA (R gave me TRUE).
Also, I aspected that if I change the order of the df in mapply()
, I will obtain the same result, but it's not true in my case. The dataframes also have different levels, so df1==df2
doesn't work.
I also will ask to you how I will count the FALSE in the result. Is there something like is.na()
?
thank you all