[Rd] Default values in control list of function

From: Prof. John C Nash <nashjc_at_uottawa.ca>
Date: Sat, 25 Jun 2011 21:21:58 -0400


In building a function for a package, I'd like to set the defaults in a control list,

e.g.,

makeg<-function(parameters, eps = 1.0e-7, control=list(showwork=TRUE, rubbish=1.0e+101)){

    etc.
}

This does not provide showwork or rubbish within the function if control() is not fully specified. Copying others, I've previously set the control defaults within the function then matched names, and that certainly works. I'm happy to keep using that approach, but would like to have a pointer to good practice for doing this (I'm prepared to write or help write a short tutorial if none exists).

I can understand that trying to do the default replacement at a second or greater level could give problems. A search through the language definition and some googling didn't show up any obvious warning about this, but I'm sure there are some comments somewhere. Can anyone suggest some URLs?

One gets used to the nicety of being able to specify defaults and forgets that even R has some limits.

JN



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon 27 Jun 2011 - 06:41:40 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 27 Jun 2011 - 12:40:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive