I'm trying to insert values from one dataset A column x that has 23 less rows to another dataset B with the same column x but filled with NA. Both datasets have column "id" and I want to fill empty column with values where id's from both datasets match and with "None" where rows are missing. I created column results to not mess up my outputs (id is integer and x is a factor).
So far I have this: $
A <- data.frame (id = c("1", "11", "2"),
x = c("123", "420", "3"))
B <- data.frame (id = c("1", "11", "2", "5", "6"),
x = c("NA", "NA", "NA", "NA", "NA"))
A$results = ifelse(A$id == B$id, insert(A$x),
ifelse(A$id != B$id, 'None'))
$ but there is an error: In A$id == B$id : longer object length is not a multiple of shorter object length
Missing values are not at the end of the dataset.