A user has two lists and want to interleaf an element of two lists into one.How to do that?
Let us create two lists.
l1 <- list('a.1','a.2', 'a.3')
l2 <- list('b.1','b.2', 'b.3', 'b.4')
We can do the following way
index <- order(c(seq_along(l1), seq_along(l2))) unlist(c(l1,l2))[index] # [1] "a.1" "b.1" "a.2" "b.2" "a.3" "b.3" "b.4"