generate: Generate an lvec with (random) values

Description Usage Arguments Value Examples

View source: R/generate.R

Description

Generate an lvec with (random) values

Usage

1
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

1
2
3
4
5
# 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)

ldat documentation built on March 26, 2020, 7:59 p.m.

Related to generate in ldat...