EVOLUTION-MANAGER
Edit File: as_vector.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: Coerce a list to a 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 as_vector {purrr}"><tr><td>as_vector {purrr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Coerce a list to a vector</h2> <h3>Description</h3> <p><code>as_vector()</code> collapses a list of vectors into one vector. It checks that the type of each vector is consistent with <code>.type</code>. If the list can not be simplified, it throws an error. <code>simplify</code> will simplify a vector if possible; <code>simplify_all</code> will apply <code>simplify</code> to every element of a list. </p> <h3>Usage</h3> <pre> as_vector(.x, .type = NULL) simplify(.x, .type = NULL) simplify_all(.x, .type = NULL) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>.x</code></td> <td> <p>A list of vectors</p> </td></tr> <tr valign="top"><td><code>.type</code></td> <td> <p>A vector mold or a string describing the type of the input vectors. The latter can be any of the types returned by <code><a href="../../base/html/typeof.html">typeof()</a></code>, or "numeric" as a shorthand for either "double" or "integer".</p> </td></tr> </table> <h3>Details</h3> <p><code>.type</code> can be a vector mold specifying both the type and the length of the vectors to be concatenated, such as <code>numeric(1)</code> or <code>integer(4)</code>. Alternatively, it can be a string describing the type, one of: "logical", "integer", "double", "complex", "character" or "raw". </p> <h3>Examples</h3> <pre> # Supply the type either with a string: as.list(letters) %>% as_vector("character") # Or with a vector mold: as.list(letters) %>% as_vector(character(1)) # Vector molds are more flexible because they also specify the # length of the concatenated vectors: list(1:2, 3:4, 5:6) %>% as_vector(integer(2)) # Note that unlike vapply(), as_vector() never adds dimension # attributes. So when you specify a vector mold of size > 1, you # always get a vector and not a matrix </pre> <hr /><div style="text-align: center;">[Package <em>purrr</em> version 0.3.4 <a href="00Index.html">Index</a>]</div> </body></html>