[R] Checking for and adding ... arguments to a function...

2014-02-17 Thread Jonathan Greenberg
R-helpers: I'm guessing this is an easy one for some of you, but I'm a bit stumped. Given some arbitrary function (doesn't matter what it does): myfunction - function(a,b,c) { return(a+b+c) } I want to test this function for the presence of the ellipses (...) and, if they are missing, create a

Re: [R] Checking for and adding ... arguments to a function...

2014-02-17 Thread David Winsemius
On Feb 17, 2014, at 1:22 PM, Jonathan Greenberg wrote: R-helpers: I'm guessing this is an easy one for some of you, but I'm a bit stumped. Given some arbitrary function (doesn't matter what it does): myfunction - function(a,b,c) { return(a+b+c) } I want to test this function for

Re: [R] Checking for and adding ... arguments to a function...

2014-02-17 Thread Ista Zahn
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

Re: [R] Checking for and adding ... arguments to a function...

2014-02-17 Thread Rui Barradas
Hello, Use ?formals. formals(myfunction) $a $b $c $... Hope this helps, Rui Barradas Em 17-02-2014 21:22, Jonathan Greenberg escreveu: R-helpers: I'm guessing this is an easy one for some of you, but I'm a bit stumped. Given some arbitrary function (doesn't matter what it does):