[R] Stacking Vectors/Dataframes

hadley wickham h.wickham at gmail.com
Mon Aug 16 15:50:55 CEST 2004


Hi Laura,

Off the top of my head I'd suggest something like this (assuming your
data frames are named a and b)

a$ord <- 1:nrow(a)
b$ord <- (1:nrow(b))*2
c <- rbind(a, b)
c <- c[order(c$ord), ]

ie.  add a new column that has the desired ordering, then join the two
data frames together, then reorder.  (code not checked).

Hadley




More information about the R-help mailing list