Interleave vectors

Share:

Description

Interleave two vectors of arbitrary length.

Usage

1
interleave(x, y)

Arguments

x

first vector to interleave.

y

second vector to interleave.

Details

x and y need not be of the same length nor of the same class.

Value

An interleaved vector.

Author(s)

Antoine Filipovic Pierucci

References

Original function posted on R-help by Bogdan Romocea.

Examples

1
2
3
4
5
6
7
8
9
# 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)