I have two data sets which contains common "id" variable.
dat1=data.frame(id = rep(1:3,3),
var1 = c(1:9),var2=(11:19))
dat2=data.frame(id= c(1:3), var3=(2:4), var4=(50:52))
What I'm going to do is combine var1 and var4 with respect to id. So the final data set should be like as follow.
dat3=cbind(dat1, var4=c(50,50,50,51,51,51,52,52,52))
I think merge
function cannot combine columns.
Is there any function I can get dat3 simply?