Hi to all, is there a better way instead for loop to merge two vectors: V1 <- c(1,3,5,7,9) V2<- c(20,40,60,80,100) to V_merged <- c(1,20,3,40,5,60,7,80,9,100) Kind regards Knut
On May 14, 2010, at 7:22 AM, Knut Krueger wrote:> Hi to all, > > is there a better way instead for loop to merge two vectors: > > V1 <- c(1,3,5,7,9) > V2<- c(20,40,60,80,100) > to > V_merged <- c(1,20,3,40,5,60,7,80,9,100) > > Kind regards > KnutTry this:> as.vector(rbind(V1, V2))[1] 1 20 3 40 5 60 7 80 9 100 This presumes that both vectors are of the same length. HTH, Marc Schwartz