[Rd] plot(1:10,c(1)$nothing) yields index plot (PR#482)

Thomas Lumley thomas@biostat.washington.edu
Mon, 13 Mar 2000 11:27:42 -0800 (PST)


On Mon, 13 Mar 2000 cberry@tajo.ucsd.edu wrote:

> <<insert bug report here>>
> 
> IMHO, 
> 
> 	plot(x,c(1)$nothing)
> 
> should fail or at least issue a warning.
> 
> Instead it produces an index plot of the first argument, i.e. plot(x)

No, the alternative is worse.

The ability to do plot(x) with x a vector is important.  One might think
that in 
	plot(x,y=NULL)
we could test for missing(y) rather than is.null(y) and issue a warning if
y was NULL but not missing.  More-or-less equivalently we could use
substitute(y) to check whether y was a literal NULL or an expression
evaluating to NULL.

This turns out to be a bad idea, because we must be able to call plot(x)
from other functions (with arbitrarily deep nesting), and it becomes very
messy to trick plot() into handling the arguments correctly as they are
passed from one function to another. 

Since plot(x) can't tell whether the NULL argument is deliberate or
accidental, it shouldn't try to guess and give a warning.


	-thomas

Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._