[Rd] good practice for values not provided

From: Tamas K Papp <tpapp_at_princeton.edu>
Date: Sun 19 Nov 2006 - 20:46:31 GMT


Hi,

I am writing a collection of functions which I plan to share as a package later (when they are tested thoroughly), so I would like to do things "right" from the beginning...

I encountered a minor question of style. Consider a function

f <- function(a,b,x=NULL) {
  ## ...
}

if !is.null(x), f will use x to calculate the result, but if is.null(x), it will do something else not involving x at all (using any x would be meaningless here, so I can't use x=calcsomethingfrom(a,b)).

What's the accepted way of indicating this in R with a default for x? x=FALSE? x=NA? x=NULL?

Thanks,

Tamas



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon Nov 20 07:49:34 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 20 Nov 2006 - 06:30:42 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.