identifyVectorArgs | R Documentation |
When running arbitrary functions inside other functions, there is a common
construct in R to use ...
. It does not work, however, in the general case
to write do.call(fn, list(...))
because not all fn
themselves
accept ...
. So this will fail if too many arguments are supplied to
the ...
. In the general case, we want to write:
do.call(fn, list(onlyTheArgumentsThatAreNeeded))
. This function helps
to find the onlyTheArgumentsThatAreNeeded
by determining a) what is needed
by the fn
(which can be a list of many fn
), and b) where to find
values, either in an arbitrary environment or passed in via dots
.
identifyVectorArgs(fn, localFormalArgs, envir, dots)
fn |
A function or list of functions from which to run |
localFormalArgs |
A vector of possible objects, e.g., from |
envir |
The environment to find the objects named in |
dots |
Generally list(...), which would be an alternative place to find
|
A list of length 2, named argsSingle
and argsMulti
, which
can be passed to e.g.,
MapOrDoCall(fn, multiple = args1$argsMulti, single = args1$argsSingle)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.