Hi,
May be this helps:
a <- 1:3
 b <- 4:6
 z <- as.vector(rbind(a,b))
 z
#[1] 1 4 2 5 3 6


#or
z1 <- setNames(c(a,b),rep(seq_along(a),2))
z1 <- as.vector(z1[order(names(z1))])
z1
#[1] 1 4 2 5 3 6
A.K.


Dear R users, 

Given two vectors x and y 
a=1 2 3 
b=4 5 6 

i want to combine them into a single vector z as 1 4 2 5 3 6 

Thanks for your help 

Tham

______________________________________________
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.

Reply via email to