EVOLUTION-MANAGER
Edit File: rerun.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: Re-run expressions multiple times.</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 rerun {purrr}"><tr><td>rerun {purrr}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Re-run expressions multiple times.</h2> <h3>Description</h3> <a href='https://www.tidyverse.org/lifecycle/#questioning'><img src='figures/lifecycle-questioning.svg' alt='Questioning lifecycle'></a> <p>This is a convenient way of generating sample data. It works similarly to <code><a href="../../base/html/lapply.html">replicate</a>(..., simplify = FALSE)</code>. </p> <h3>Usage</h3> <pre> rerun(.n, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>.n</code></td> <td> <p>Number of times to run expressions</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Expressions to re-run.</p> </td></tr> </table> <h3>Value</h3> <p>A list of length <code>.n</code>. Each element of <code>...</code> will be re-run once for each <code>.n</code>. </p> <p>There is one special case: if there's a single unnamed input, the second level list will be dropped. In this case, <code>rerun(n, x)</code> behaves like <code>replicate(n, x, simplify = FALSE)</code>. </p> <h3>Lifecycle</h3> <p><code>rerun()</code> is in the questioning lifecycle stage because we are no longer convinced NSE functions are a good fit for purrr. Also, <code>rerun(n, x)</code> can just as easily be expressed as <code>map(1:n, ~ x)</code> (with the added benefit of being passed the current index as argument to the lambda). </p> <h3>Examples</h3> <pre> 10 %>% rerun(rnorm(5)) 10 %>% rerun(x = rnorm(5), y = rnorm(5)) %>% map_dbl(~ cor(.x$x, .x$y)) </pre> <hr /><div style="text-align: center;">[Package <em>purrr</em> version 0.3.4 <a href="00Index.html">Index</a>]</div> </body></html>