[Rd] Changing function arguments to NULL

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Feb 28 23:28:34 CET 2005


On Mon, 28 Feb 2005, McGehee, Robert wrote:

> But passing list(NULL) or NULL into a function may have entirely
> different results.

For a replacement operator expecting a list, list(NULL) *is* what you 
want.  BTW, this is FAQ 7.1.

> foo <- alist(x = 5, y = 2, z = 3)
> foo["x"] <- list(NULL)
> foo
$x
NULL

$y
[1] 2

$z
[1] 3

if (as I guess) you want to set the default value to NULL, not `the 
argument to NULL'.

[...]

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list