I would like to fill out the missing values in df1 using df2:
df1 <- data.frame(
ID = c("1", "2", "3", "4"),
value = c("A", "B", NA, NA)
)
df2 <- data.frame(
ID = c("3", "4"),
value = c("C", "D")
)
I would like to have:
ID value
1 A
2 B
3 C
4 D
Using left_join() from the dplyr package produces:
left_join(df1, df2, by=c("ID"))
ID value.x value.y
1 A <NA>
2 B <NA>
3 <NA> C
4 <NA> D
What is the correct dplyr method to perform this operation?