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 > Knut
Try 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 ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.