R can merge two data sets that have a same type of reference variable. Intuitively, the command is "merge."
# example
dat1 <- data.frame(id=c(1, 1, 1, 2, 2, 2),
sex=c("m", "m", "m", "f", "f", "f"))
dat2 <- data.frame(p.id=c(1, 2), income=c(23451, 21232))
merge(dat1, dat2, by.x="id", by.y="p.id")
4 hours ago
1 comment:
That was great, 感謝!
Post a Comment