Skip to content
Prev 22947 / 63424 Next

good practice for values not provided

On 11/19/2006 3:46 PM, Tamas K Papp wrote:
I think the most common is x=NULL, but probably all of those are used in 
some package.  The advantage some default over no default and an 
is.missing(x) test, is that you can write g to call f with the same default:

g <- function(a,b,c,d,x=NULL) {
   f(a,b,x)
   # some more stuff
}

It would be harder if you wanted to signal missing x by not including it 
in the call, because you'd need a test in g.

Duncan Murdoch