EVOLUTION-MANAGER
Edit File: flatten.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: Flatten a list of lists into a simple 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 flatten {purrr}"><tr><td>flatten {purrr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Flatten a list of lists into a simple vector.</h2> <h3>Description</h3> <p>These functions remove a level hierarchy from a list. They are similar to <code><a href="../../base/html/unlist.html">unlist()</a></code>, but they only ever remove a single layer of hierarchy and they are type-stable, so you always know what the type of the output is. </p> <h3>Usage</h3> <pre> flatten(.x) flatten_lgl(.x) flatten_int(.x) flatten_dbl(.x) flatten_chr(.x) flatten_raw(.x) flatten_dfr(.x, .id = NULL) flatten_dfc(.x) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>.x</code></td> <td> <p>A list to flatten. The contents of the list can be anything for <code>flatten()</code> (as a list is returned), but the contents must match the type for the other functions.</p> </td></tr> <tr valign="top"><td><code>.id</code></td> <td> <p>Either a string or <code>NULL</code>. If a string, the output will contain a variable with that name, storing either the name (if <code>.x</code> is named) or the index (if <code>.x</code> is unnamed) of the input. If <code>NULL</code>, the default, no variable will be created. </p> <p>Only applies to <code style="white-space: pre;">_dfr</code> variant.</p> </td></tr> </table> <h3>Value</h3> <p><code>flatten()</code> returns a list, <code>flatten_lgl()</code> a logical vector, <code>flatten_int()</code> an integer vector, <code>flatten_dbl()</code> a double vector, and <code>flatten_chr()</code> a character vector. </p> <p><code>flatten_dfr()</code> and <code>flatten_dfc()</code> return data frames created by row-binding and column-binding respectively. They require dplyr to be installed. </p> <h3>Examples</h3> <pre> x <- rerun(2, sample(4)) x x %>% flatten() x %>% flatten_int() # You can use flatten in conjunction with map x %>% map(1L) %>% flatten_int() # But it's more efficient to use the typed map instead. x %>% map_int(1L) </pre> <hr /><div style="text-align: center;">[Package <em>purrr</em> version 0.3.4 <a href="00Index.html">Index</a>]</div> </body></html>