How can I concatenate two vectors to get a vector with values alternatively from the first and second one?
Input
a<- c(1,2,3)
b<- c(4,5,6)
Output
c(1,4,2,5,3,6)
How can I concatenate two vectors to get a vector with values alternatively from the first and second one?
Input
a<- c(1,2,3)
b<- c(4,5,6)
Output
c(1,4,2,5,3,6)
This is one way
> as.numeric(t(matrix(c(a,b), ncol = 2)))
[1] 1 4 2 5 3 6