[R] merging two vectors
Marc Schwartz
marc_schwartz at me.com
Fri May 14 14:36:51 CEST 2010
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
More information about the R-help
mailing list