mapplyRecursively apply a function to a list or lists.
rMapply(FUN, ..., MoreArgs = NULL, SIMPLIFY = TRUE, USE.NAMES = TRUE)Function to apply.
Object(s) to which FUN can be applied, or lists of such
objects to iterate over (defined narrowly, as of class "list").
A list of additional arguments to FUN.
Logical, whether to simplify the results to a vector or array.
Logical, whether to use the names of the first list object
in ... for the output.
The output of FUN in a list or nested list, or simplified to a
vector or array (or list of arrays).
rMapply recursively applies FUN to the elements of the
lists in ... via mapply. If only a single list
is supplied, the function acts like a recursive version of
sapply. The particular condition that determines if the
function should stop recursing is if either the first or second objects in
... are not of class "list". Thus, unlike mapply, it
will not iterate over non-list elements in these objects, but instead
returns the output of FUN(...).
This is primarily a convenience function used internally to enable
recursive application of functions to lists or nested lists. Its particular
stop condition for recursing is also designed to either a) act as a wrapper
for FUN if the first object in ... is not a list, or b) apply
a weighted averaging operation if the first object is a list and the second
object is a numeric vector of weights.