I have a main table(a), containing column: id, age, and sex. eg.
a <- data.frame(id=letters[1:4], age=c(18,NA,9,NA), sex=c("M","F","F","M"))
id age sex
1 a 18 M
2 b NA F
3 c 9 F
4 d NA M
And I have a supplement table(b), just containing all the missing data in table(a) or duplicated data in table(a). eg.
b <- data.frame(id=c("a","b","d"), age=c(18,32,20))
id age
1 a 18
2 b 32
3 d 20
Now I want to merge the two table, like this:
id age sex
1 a 18 M
2 b 32 F
3 c 9 F
4 d 20 M
However, I'd tried merge(a,b,by="id",all=T)
. The result is not what I want. Is there any way to solve this problem? Thank you!