I would like to weave two data.frame into R. For example:
a = data.frame(x=1:5, y=5:1) b = data.frame(x=2:6, y=4:0)
I would like the result to look like this:
> xy 1 5 2 4 2 4 3 3 3 3 ...
it turns out cbind ing x[1] with y[1] , x[2] with y[2] , etc.
What is the cleanest way to do this? Right now, my solution includes splashing out the entire list and merging. This is pretty ugly:
lst = lapply(1:length(x), function(i) cbind(x[i,], y[i,])) res = do.call(rbind, lst)
Alex
source share