Description Usage Arguments Value Author(s) References Examples
This function takes two vectors and merges them, by means of an in shuffle. Every other value in the result vector originates from the same source vector; values in odd-numbered positions are from vector A, while even-numbered positions are occupied by values from vector B. The ordering of the original values is preserved.
1 | interleave(a, b)
|
a |
A vector |
b |
A second vector |
An interleaved vector with length equal to length(A) + length(B)
.
Arun Srinivasan
https://stackoverflow.com/questions/16443260/interleave-lists-in-r
1 2 3 4 5 | a <- c(1, 2, 3)
b <- c(4, 5, 6)
interleave(a, b) # returns 1 4 2 5 3 6
interleave(as.character(a), as.character(b)) # returns "1" "4" "2" "5" "3" "6"
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.