Created
June 6, 2011 20:13
-
-
Save cboettig/1010999 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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