Compare two data frames to change the value of a variable in R
I am trying to compare two data frames with the same number of rows and variables, to change the value of the variable to a unique identifier (return True if the value is the same and false if it is different). Here's an example of what the data looks like:
df1
id col1 col2
1 abc 123
2 def 456
3 ghi 789
df2
col1 id col2
ghe 3 789
abc 1 123
def 2 455
And I think the comparison result would be in df3
id col1 col2
1 true true
2 true false
3 false true
Any help would be greatly appreciated! I hope I've made this somewhat clear.
+3
source to share