merge関数を使う
> x <- data.frame(id = c(1,2,3), name = c("a", "b", "c")) > y <- data.frame(id = c(1,2,3,4), age = c(12, 10, 11, 9)) > merge(x, y, "id") id name age 1 1 a 12 2 2 b 10 3 3 c 11 > merge(x, y, "id", all = T) id name age 1 1 a 12 2 2 b 10 3 3 c 11 4 4 <NA> 9 >
参考