Skip to content
Prev 243687 / 398513 Next

default arguments and '...' in a function

On Wed, Dec 1, 2010 at 2:34 PM, <Antonio.Gasparrini at lshtm.ac.uk> wrote:
Try using modifyList as shown:

# simple function for illustration
somefunction <- function(a, b, c) sprintf("a: %d, b: %d, c: %d", a, b, c)

f <- function(a, ...) {
   L <- modifyList(list(b = 1, c = 1), list(a = a, ...))
   do.call(somefunction, L)
}

f(5, c = 3) # "a: 5, b: 1, c: 3"