generate: Generate an lvec with (random) values

View source: R/generate.R

generateR Documentation

Generate an lvec with (random) values

Description

Generate an lvec with (random) values

Usage

generate(n, fun, ..., chunk_size = 5e+06)

Arguments

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 fun.

chunk_size

the size of the chunks of values with which to fill the resulting lvec. When not given it uses the value of the option 'chunk_size' (see options) otherwise the default value.

Value

Returns an lvec with length n. The type is determined by the type of values returned by fun.

Examples

# 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)


djvanderlaan/lvec_stats documentation built on Oct. 4, 2022, 7:02 p.m.