Skip to content

Instantly share code, notes, and snippets.

@cboettig
Created June 6, 2011 20:13
Show Gist options
  • Save cboettig/1010999 to your computer and use it in GitHub Desktop.
Save cboettig/1010999 to your computer and use it in GitHub Desktop.
## this function f will remember whatever options it is passed
f <- function(y, ...){
out <- y + dnorm(...)
list(out, opts=list(...))
}
## This is the way to call the function using its exact arguments
a <- f(1, x=4, sd=2, mean=4)
b <- do.call(f, c(list(y=1), a$opt))
identical(a,b) # TRUE
## These ways will not give the same output
f(1, unlist(a$opts))
f(1, a$opts[[1]])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment