View source: R/slice-interleave.R
vec_interleave | R Documentation |
vec_interleave()
combines multiple vectors together, much like vec_c()
,
but does so in such a way that the elements of each vector are interleaved
together.
It is a more efficient equivalent to the following usage of vec_c()
:
vec_interleave(x, y) == vec_c(x[1], y[1], x[2], y[2], ..., x[n], y[n])
vec_interleave(
...,
.ptype = NULL,
.name_spec = NULL,
.name_repair = c("minimal", "unique", "check_unique", "universal", "unique_quiet",
"universal_quiet")
)
... |
Vectors to interleave. These will be recycled to a common size. |
.ptype |
If Alternatively, you can supply |
.name_spec |
A name specification for combining
inner and outer names. This is relevant for inputs passed with a
name, when these inputs are themselves named, like
See the name specification topic. |
.name_repair |
How to repair names, see |
list_unchop()
# The most common case is to interleave two vectors
vec_interleave(1:3, 4:6)
# But you aren't restricted to just two
vec_interleave(1:3, 4:6, 7:9, 10:12)
# You can also interleave data frames
x <- data_frame(x = 1:2, y = c("a", "b"))
y <- data_frame(x = 3:4, y = c("c", "d"))
vec_interleave(x, y)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.