dlapply: Apply Functions Over Data List Margins

Description Usage Arguments Details Value Examples

Description

Returns a data list (or list of data lists) obtained by attempting to apply a function to margins of each variable in a data list.

Usage

1
2
3
4
5
dlapply(X, MARGIN, FUN, ...)

sdlapply(X, MARGIN, FUN, simplify = TRUE, ...)

variable_margins(X, MARGIN)

Arguments

X

A data list

MARGIN

See apply.

FUN

See apply.

simplify

Should the result be simplified to a data frame?

...

Optional arguments to FUN.

Details

Essentially, dlapply works by passing each variable in X to apply. For each variable, the dimensions identified by MARGIN are only used if that variable is replicated along that dimension.

Because data lists may contain very different variables, it is not guaranteed that FUN will generate anything useful for each variable in X. If an error occurs during a call to apply, that variable is simply removed from the output with a message. Variables may also be removed (also with a message) because they are not replicated along any of the dimensions specified by MARGIN.

FUN may induce a new dimension to the data list because its return value has length greater than one. In this case, the new dimension is called as.character(substitute(FUN)). However, if the length of this new dimension differs among variables, then a data list cannot be constructed and instead a list of the variables (in data list form) is returned (with a message).

The variable_margins function returns a list with one vector for each variable, giving the value for MARGIN when passing X to apply. This is helpful when figuring out why dlcast results in an error.

Value

A data list or list of data lists.

Examples

1
2
3

stevencarlislewalker/multitable documentation built on May 30, 2019, 4:44 p.m.