EVOLUTION-MANAGER
Edit File: vec_interleave.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Interleave many vectors into one vector</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for vec_interleave {vctrs}"><tr><td>vec_interleave {vctrs}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Interleave many vectors into one vector</h2> <h3>Description</h3> <p><code>vec_interleave()</code> combines multiple vectors together, much like <code><a href="vec_c.html">vec_c()</a></code>, but does so in such a way that the elements of each vector are interleaved together. </p> <p>It is a more efficient equivalent to the following usage of <code>vec_c()</code>: </p> <div class="sourceCode"><pre>vec_interleave(x, y) == vec_c(x[1], y[1], x[2], y[2], ..., x[n], y[n]) </pre></div> <h3>Usage</h3> <pre> vec_interleave( ..., .ptype = NULL, .name_spec = NULL, .name_repair = c("minimal", "unique", "check_unique", "universal", "unique_quiet", "universal_quiet") ) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>...</code></td> <td> <p>Vectors to interleave. These will be <a href="vector_recycling_rules.html">recycled</a> to a common size.</p> </td></tr> <tr valign="top"><td><code>.ptype</code></td> <td> <p>If <code>NULL</code>, the default, the output type is determined by computing the common type across all elements of <code>...</code>. </p> <p>Alternatively, you can supply <code>.ptype</code> to give the output known type. If <code>getOption("vctrs.no_guessing")</code> is <code>TRUE</code> you must supply this value: this is a convenient way to make production code demand fixed types.</p> </td></tr> <tr valign="top"><td><code>.name_spec</code></td> <td> <p>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 <code>outer = c(inner = 1)</code>, or when they have length greater than 1: <code>outer = 1:2</code>. By default, these cases trigger an error. You can resolve the error by providing a specification that describes how to combine the names or the indices of the inner vector with the name of the input. This specification can be: </p> <ul> <li><p> A function of two arguments. The outer name is passed as a string to the first argument, and the inner names or positions are passed as second argument. </p> </li> <li><p> An anonymous function as a purrr-style formula. </p> </li> <li><p> A glue specification of the form <code>"{outer}_{inner}"</code>. </p> </li> <li><p> An <code><a href="../../rlang/html/zap.html">rlang::zap()</a></code> object, in which case both outer and inner names are ignored and the result is unnamed. </p> </li></ul> <p>See the <a href="name_spec.html">name specification topic</a>.</p> </td></tr> <tr valign="top"><td><code>.name_repair</code></td> <td> <p>How to repair names, see <code>repair</code> options in <code><a href="vec_as_names.html">vec_as_names()</a></code>.</p> </td></tr> </table> <h3>Dependencies</h3> <h4>vctrs dependencies</h4> <ul> <li> <p><code><a href="vec_chop.html">list_unchop()</a></code> </p> </li></ul> <h3>Examples</h3> <pre> # 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) </pre> <hr /><div style="text-align: center;">[Package <em>vctrs</em> version 0.5.0 <a href="00Index.html">Index</a>]</div> </body></html>