R/MapOrDoCall.R
identifyVectorArgs.RdWhen 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)A function or list of functions from which to run formalArgs
A vector of possible objects, e.g., from ls()
The environment to find the objects named in localFormalArgs
Generally list(...), which would be an alternative place to find
localFormalArgs
A list of length 2, named argsSingle and argsMulti, which
can be passed to e.g.,
MapOrDoCall(fn, multiple = args1$argsMulti, single = args1$argsSingle)