Adding data to column dependent on match

Viewed 68

I am trying to merge data from one dataframe to another. I suppose this is an easy question for everybody here. But I cant seem to get the right result. So something like.

df1 <- data.frame(X=c("aap","rel","kop"), Y=c(500,12,350))
df2 <- data.frame(X=c("lee","1su","eeu","ggu", "ees"), Y=c(100,12,350,80,50)) 
df3 <- merge(df1, df2)

The result should be:

df3 <- data.frame(X=c("aap","rel","kop", "lee","1su","eeu","ggu", "ees"), 
                 Y=c(500,12,350,100,12,350,80,50) 
1 Answers
Related