Suppose I have a specific value x (unique) that is contained in df1. I want to match this value x (unique) with the value x (unique) contained in df2 so to obtain the correspondent value "date". The problem is that df1 and df2 have two different row lengths, thus the following function won't work:
match(df1$x,df2$x)
df2$date[match(df1$x,df2$x)]
df1$date = df2$date[match(df1$x,df2$x)]
Example df1 and df2:
df1-->
x | y | a | b |
1 2 6 9
2 2 7 2
3 4 8 1
4 5 7 2
df2-->
x | z | date | l | m |
1 2 1987 a c
2 2 1989 b c
3 2 1986 a d
Example final result: df1 -->
x | y | date
1 2 1987
2 2 1989
3 2 1986