Hi, my actual datasets are way too large to share so I made 2 example data frames
df1 <- data.frame(w=c("abc", "def", "ghi", "jkl", "mno", "pqr", "stu", "vwx", "yzA", "BCD"), a=rep(c(0:1), times =5), b=rep(0, times= 2), c=c(0, 5, 0, 9, 6, 7, 7, 0, 0, 3))
df2 <- data.frame(w=c("abc", "def", "ghi", "jkl", "mno"), f=c(1, 2, 5, 7, 3))
These are my 2 example dataframes I want to merge based on the names of column w.
df_merged <- data.frame(w=c("abc", "def", "ghi", "jkl", "mno", "pqr", "stu", "vwx", "yzA", "BCD"), a=rep(c(0:1), times =5), b=rep(0, times= 2), c=c(0, 5, 0, 9, 6, 7, 7, 0, 0, 3), f=c(1,2,5,7,3,0,0,0,0,0))
This would be my ideal output data frame. So the df2 rows that match based on column w will be matched, and the row that are then missing, will have a 0 on that place.
I already figured out that I should use the merge function, but I do not know how.
Can anyone help me?