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, <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 of plots. Every different plot should have different default arguments >> (for example for 'col', 'ylim' etc), plus the argument '...' to leave >> further optional choices to the user. >> My problem is that I need to specify a large number of arguments in the >> usage (losing clarity), or alternatively leaving to the user the >> specification of an high number of argument (adding complexity). >> >> An example. >> Suppose I want to create a function f with arguments 'a', and '...'. >> Two more arguments 'b' and 'c' should be both set to 1 by default if the >> user don't include them in '...'. >> >> f <- function(a,...) { >> # set b <- 1 if b is not included in '...' >> # set c <- 1 if c is not included in '...' >> somefunction(a,b,c,...) >> } >> Bert Gunter Genentech ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.