a1 <- data.frame(id=c(1,1,1,1,2,2,2,3,3),
var=c("6402","1","1","3","6406","6406","2","1","1"))
b1 <- data.frame(var=c("6402","6406"),
txt=c("A","B"))
n1 <- data.frame(id=c(1,2,3))
desired <- data.frame(id=c(1,2,3),
txt=c("A","B",NA))
How can I join a1,b1 and n1 to generate the desired df?