Skip to content
Prev 336728 / 398513 Next

Checking for and adding "..." arguments to a function...

Here are two ways:

## construct formals adding ...
f <- c(formals(myfunction), unlist(alist(... = )))
## replace the formals, excluding the extra ... if it previously existed
formals(myfunction) <- f[!duplicated(names(f))]


## 2nd way, searching for ... and doing the replacement only if it is not found
if(!any(grepl("...", names(formals(myfunction))))) {
    formals(myfunction) <- c(formals(myfunction), unlist(alist(... = )))
}

HTH,
Ista
On Mon, Feb 17, 2014 at 4:22 PM, Jonathan Greenberg <jgrn at illinois.edu> wrote: