I'm trying to mark rows of a bigger dataframe that are common with a smaller dataframe.
I've looked into similar topics (find the common ids between two data frames in R Find indices of duplicated rows Finding ALL duplicate rows, including "elements with smaller subscripts"), but couldn't figure out how to make it work the following way:
df1<- data.frame(id = c(1, 2, 3, 4, NA, 5, 6, NA, NA, 7, 8))
df2<- data.frame(id = c(NA, 8, 3, NA, 1))
# Result
> df1
id match
1 1 TRUE
2 2 FALSE
3 3 TRUE
4 4 FALSE
5 NA FALSE
6 5 FALSE
7 6 FALSE
8 NA FALSE
9 NA FALSE
10 7 FALSE
11 8 TRUE