EVOLUTION-MANAGER
Edit File: vec_c.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: Combine 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_c {vctrs}"><tr><td>vec_c {vctrs}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Combine many vectors into one vector</h2> <h3>Description</h3> <p>Combine all arguments into a new vector of common type. </p> <h3>Usage</h3> <pre> vec_c( ..., .ptype = NULL, .name_spec = NULL, .name_repair = c("minimal", "unique", "check_unique", "universal", "unique_quiet", "universal_quiet"), .error_arg = "", .error_call = current_env() ) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>...</code></td> <td> <p>Vectors to coerce.</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> <tr valign="top"><td><code>.error_arg</code></td> <td> <p>An argument name as a string. This argument will be mentioned in error messages as the input that is at the origin of a problem.</p> </td></tr> <tr valign="top"><td><code>.error_call</code></td> <td> <p>The execution environment of a currently running function, e.g. <code>caller_env()</code>. The function will be mentioned in error messages as the source of the error. See the <code>call</code> argument of <code><a href="../../rlang/html/abort.html">abort()</a></code> for more information.</p> </td></tr> </table> <h3>Value</h3> <p>A vector with class given by <code>.ptype</code>, and length equal to the sum of the <code>vec_size()</code> of the contents of <code>...</code>. </p> <p>The vector will have names if the individual components have names (inner names) or if the arguments are named (outer names). If both inner and outer names are present, an error is thrown unless a <code>.name_spec</code> is provided. </p> <h3>Invariants</h3> <ul> <li> <p><code>vec_size(vec_c(x, y)) == vec_size(x) + vec_size(y)</code> </p> </li> <li> <p><code>vec_ptype(vec_c(x, y)) == vec_ptype_common(x, y)</code>. </p> </li></ul> <h3>Dependencies</h3> <h4>vctrs dependencies</h4> <ul> <li> <p><code><a href="vec_cast.html">vec_cast_common()</a></code> with fallback </p> </li> <li> <p><code><a href="vec_proxy.html">vec_proxy()</a></code> </p> </li> <li> <p><code><a href="vec_proxy.html">vec_restore()</a></code> </p> </li></ul> <h4>base dependencies</h4> <ul> <li> <p><code><a href="../../base/html/c.html">base::c()</a></code> </p> </li></ul> <p>If inputs inherit from a common class hierarchy, <code>vec_c()</code> falls back to <code>base::c()</code> if there exists a <code>c()</code> method implemented for this class hierarchy. </p> <h3>See Also</h3> <p><code><a href="vec_bind.html">vec_cbind()</a></code>/<code><a href="vec_bind.html">vec_rbind()</a></code> for combining data frames by rows or columns. </p> <h3>Examples</h3> <pre> vec_c(FALSE, 1L, 1.5) # Date/times -------------------------- c(Sys.Date(), Sys.time()) c(Sys.time(), Sys.Date()) vec_c(Sys.Date(), Sys.time()) vec_c(Sys.time(), Sys.Date()) # Factors ----------------------------- c(factor("a"), factor("b")) vec_c(factor("a"), factor("b")) # By default, named inputs must be length 1: vec_c(name = 1) try(vec_c(name = 1:3)) # Pass a name specification to work around this: vec_c(name = 1:3, .name_spec = "{outer}_{inner}") # See `?name_spec` for more examples of name specifications. </pre> <hr /><div style="text-align: center;">[Package <em>vctrs</em> version 0.5.0 <a href="00Index.html">Index</a>]</div> </body></html>