EVOLUTION-MANAGER
Edit File: repeatable.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: Make a random number generator repeatable</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 repeatable {shiny}"><tr><td>repeatable {shiny}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Make a random number generator repeatable</h2> <h3>Description</h3> <p>Given a function that generates random data, returns a wrapped version of that function that always uses the same seed when called. The seed to use can be passed in explicitly if desired; otherwise, a random number is used. </p> <h3>Usage</h3> <pre> repeatable(rngfunc, seed = stats::runif(1, 0, .Machine$integer.max)) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>rngfunc</code></td> <td> <p>The function that is affected by the R session's seed.</p> </td></tr> <tr valign="top"><td><code>seed</code></td> <td> <p>The seed to set every time the resulting function is called.</p> </td></tr> </table> <h3>Value</h3> <p>A repeatable version of the function that was passed in. </p> <h3>Note</h3> <p>When called, the returned function attempts to preserve the R session's current seed by snapshotting and restoring <code><a href="../../base/html/Random.html">base::.Random.seed()</a></code>. </p> <h3>Examples</h3> <pre> rnormA <- repeatable(rnorm) rnormB <- repeatable(rnorm) rnormA(3) # [1] 1.8285879 -0.7468041 -0.4639111 rnormA(3) # [1] 1.8285879 -0.7468041 -0.4639111 rnormA(5) # [1] 1.8285879 -0.7468041 -0.4639111 -1.6510126 -1.4686924 rnormB(5) # [1] -0.7946034 0.2568374 -0.6567597 1.2451387 -0.8375699 </pre> <hr /><div style="text-align: center;">[Package <em>shiny</em> version 1.5.0 <a href="00Index.html">Index</a>]</div> </body></html>