I am looking to merge a smaller and a bigger dataframe. Everytime I use merge() it returns the small dataframe, but I want the larger data frame where unknown "code" variables are NA.
Thanks!
bigdata <- data.frame(title = c("a", "b", "c", "d", "e", "f"))
# code title
#1 NA a
#2 NA b
#3 NA c
#4 NA d
#5 NA e
#6 NA f
smalldata <- data.frame(code = rep(1,3), title = c("a", "b", "c"))
# code title
#1 1 a
#2 1 b
#3 1 c
#I get the following output:
merge(bigdata, smalldata by = "title")
# title code
#1 a 1
#2 b 1
#3 c 1
#instead, I want something like this, with the large dataframe absorbing the codes from the #smalldata, and containing NA for unknown codes.
# title code
#1 a 1
#2 b 1
#3 c 1
#4 d NA
#5 e NA
#6 f NA