[R] default arguments and '...' in a function

2010-12-01 Thread Antonio.Gasparrini
Dear R-users, I'm trying to work out a way to set default values for arguments in a function which includes the optional argument '...'. In practice, I have a 'plot' method for a function which specifies different types of plots. Every different plot should have different default arguments

Re: [R] default arguments and '...' in a function

2010-12-01 Thread Sarah Goslee
Antonio, You need to compare the names of list(...) with the arguments you wish to check. Here's one way to do so (note that I replaced c with d, because c is a function): f - function(a, ...) { argnames - names(list(...)) # check whether b is an argument if(!(b %in%

Re: [R] default arguments and '...' in a function

2010-12-01 Thread Gabor Grothendieck
On Wed, Dec 1, 2010 at 2:34 PM, antonio.gasparr...@lshtm.ac.uk wrote: Dear R-users, I'm trying to work out a way to set default values for arguments in a function which includes the optional argument '...'. In practice, I have a 'plot' method for a function which specifies different types

Re: [R] default arguments and '...' in a function

2010-12-01 Thread Bert Gunter
Look at the code for plot.default to see how it handles this issue usling locally defined versions of functions with (possibly) locally set parameter values. Cheers, Bert On Wed, Dec 1, 2010 at 6:39 PM, Gabor Grothendieck ggrothendi...@gmail.com wrote: On Wed, Dec 1, 2010 at 2:34 PM,