do_dots: Call functions

Description Usage Arguments Details Value Examples

Description

Pass the elipsis arguemnt to one or more functions

Usage

1
do_dots(f, ..., consume = FALSE, quote = FALSE, envir = parent.frame())

Arguments

f

vector containing one or more functions or function names

...

arguments to be passed to the functions named in f

consume

if true, each function removes is arguments prior to the next call

quote

passed to do.call

envir

passed to do.call

Details

Each function named in f is executed using do.call. The additional arguments given in "..." will be matched against the formals of the subfunction. Each function will only be passed arguments matching its formals. Argument matching is recorded and any unused arguments are returned.

If consume is true, then each function called in order will remove its matching arguments from those available to the next function.

The ... arguments will be evaluated prior to do.call, so you must quote them if you want to avoid early evaluation.

Value

A list of return values from each function named in f. Each list element will be named for the function called or the name used in constructing the vector f. All unused arguments will returned in the "..." list element.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
f = function(a, b) c(a, b)
g = function(c, d) c(c, d)

h = function(...) { f(...); g(...) }
try({ h(a = 1, b = 2, c = 3, d = 4) })

do_dots(c("f", "g"), a = 1, b = 2, c = 3, d = 4, e = 5)

j = function(a, d) c(a, d)
do_dots(c("f", "j"), a = 1, b = 2, c = 3, d = 4)
try({ do_dots(c("f", "j"), a = 1, b = 2, c = 3, d = 4, consume = TRUE) })

# primitive functions use implicit ... args
do_dots("sum", rnorm(100))

thk686/dotdotdot documentation built on May 31, 2019, 10:43 a.m.