List Production (From Variable Functions)

Description

Produce a named list that allows the user to lazily pass unnamed wakefield variable functions (optionally, without call parenthesis).

Usage

1
r_list(n, ..., rep.sep = "_")

Arguments

n

The length to pass to the randomly generated vectors.

rep.sep

A separator to use for repeated variable names. For example if the age is used three times (r_list(age, age, age)), the name "Age" will be assigned to all three vectors in the list. The results in column names c("Age_1", "Age_2", "Age_3"). To turn of this behavior use rep.sep = NULL. This results in c("Age", "Age", "Age") for vector names, leading to c("Age", "Age.1", "Age.2") if coerced to a data.frame.

...

A set of optionally named arguments. Using wakefield variable functions require no name or call parenthesis.

Value

Returns a named list of equal length vectors.

Author(s)

Josh O'Brien and Tyler Rinker <tyler.rinker@gmail.com>.

References

http://stackoverflow.com/a/29617983/1000343

See Also

r_data_frame, r_series r_dummy

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
r_list(
    n = 30,
    id,
    race,
    age,
    sex,
    hour,
    iq,
    height,
    died,
    Scoring = rnorm
)

r_list(
    n = 30,
    id,
    race,
    age(x = 8:14),
    Gender = sex,
    Time = hour,
    iq,
    height(mean=50, sd = 10),
    died,
    Scoring = rnorm
)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.