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)

Arguments

fn

A function or list of functions from which to run formalArgs

localFormalArgs

A vector of possible objects, e.g., from ls()

envir

The environment to find the objects named in localFormalArgs

dots

Generally list(...), which would be an alternative place to find localFormalArgs

Value

A list of length 2, named argsSingle and argsMulti, which can be passed to e.g., MapOrDoCall(fn, multiple = args1$argsMulti, single = args1$argsSingle)