I am trying to comine two data frames such that I match the values in the vector called vec
by their index number.
vec=c(-2,-5)
y=as.data.frame(cbind(0:(length(c(vec))-1)*2+1,c(vec)))
V1 V2
1 1 -2
2 3 -5
x=as.data.frame(1:4,names="V1"); names(x)="V1"
V1
1 1
2 2
3 3
4 4
What I want is a dataframe to look like this
V1 V2
1 1 -2
2 2 NA
3 3 -5
4 4 NA
I have trying to get this command to work but as of no luck
merge(x,y,by.x="V1")