.plapply | R Documentation |
Alternate versions of plapply
, psapply
, and pvapply
which accept an argument dots
instead of ...
.
.plapply(X, FUN, dots = NULL)
.psapply(X, FUN, dots = NULL, simplify = TRUE, USE.NAMES = TRUE)
.pvapply(X, FUN, FUN.VALUE, dots = NULL, USE.NAMES = TRUE)
X |
list of arguments to vectorize over. |
FUN |
function to apply, found via |
dots |
list of optional arguments to |
simplify |
logical or character string; should the result be simplified
to a vector, matrix, or higher dimensional array if possible? The default
value, |
USE.NAMES |
logical; if |
FUN.VALUE |
a (generalized) vector; a template for the return value from
|
While plapply
would build a call like:
FUN(X[[1L]][[j]], X[[2L]][[j]], ...)
.plapply
builds a call like:
FUN(X[[1L]][[j]], X[[2L]][[j]], dots[[1L]], dots[[2L]])
with more or less dots[[k]]
depending on the length of dots
.
Additionally, the dots
arguments in the call will be named if
dots
has names.
dots
is not coerced by base::as.list
, instead
its subsetting ([[
), length
,
and names
methods will be used.
plapply
will only evaluate its ...
argument as necessary, and
even when forced, it will only evaluate the desired elements.
In contrast, .plapply
will ALWAYS evaluate its dots
argument, even if it is never used. This is because we need to know
dots
length and names to build the call.
plapply
# you should see here that plapply will not evaluate its
# optional arguments to FUN (because they are not used in
# this example)
#
# but .plapply will evaluate its optional arguments, even
# though they are not used in this example
invisible(essentials:: plapply(NA, function(...) {
print(substitute(list(...)))
}, k = cat("evaluated optional arguments to FUN\n") ))
invisible(essentials::.plapply(NA, function(...) {
print(substitute(list(...)))
}, list(k = cat("evaluated optional arguments to FUN\n"))))
# also, plapply will only evaluate optional arguments as
# requested
invisible(essentials:: plapply(NA, function(x, ...) ..1,
cat("evaluated first optional argument to FUN\n"),
cat("evaluated second optional argument to FUN\n") ))
invisible(essentials::.plapply(NA, function(x, ...) ..1,
list(cat("evaluated first optional argument to FUN\n"),
cat("evaluated second optional argument to FUN\n"))))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.