This question already has an answer here:
Im struggling with what I feel like there must be a good vectorized way to do it but I am just not finding it. I currently have two equal length vectors and I would like to combine them but I want the first element in vector 1 followed by the first element in vector 2, then second element in vector 1 followed by the second element in vector 2, etc.
Vector1 <- c(301L, 50L, 61L, 84L, 90L) Vector2 <- c(302L, 51L, 62L, 85L, 91L)
What I want the result to be (I know I could combine them and use sort but I want to keep the order of them intact (301 & 302 come before the rest).
Vector3 <- c(301L, 302L, 50L, 51L, 61L, 62L, 84L, 85L, 90L, 91L)