interleave(x, y)
x
and y
need not be of the same length nor of the same class.
# same length
a <- letters[1:5]
b <- letters[10:15]
interleave(a, b)
# different length
x <- letters[1:2]
y <- letters[10:15]
interleave(x, y)
Run the code above in your browser using DataLab