generate | R Documentation |
Generate an lvec with (random) values
generate(n, fun, ..., chunk_size = 5e+06)
n |
number of elements in result vector |
fun |
function that generates values. Should accept a number of elements to generate as its first argument. |
... |
additional arguments are passed on to |
chunk_size |
the size of the chunks of values with which to fill the
resulting |
Returns an lvec
with length n
. The type is determined
by the type of values returned by fun
.
# generate an lvec with random normally distributed values with sd of 10 x <- generate(2E6, rnorm, sd = 10) # generate lvec with random letters; use sample; expects n as its second # argument, but we work around that by explicitly naming first argument x y <- generate(2E6, sample, x = letters, replace = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.