[R] NA values for "col"

Rolf Turner r@turner @end|ng |rom @uck|@nd@@c@nz
Mon Sep 27 23:12:30 CEST 2021


I've just noticed what seems to me to be somewhat peculiar behaviour in
respect of how different plotting functions treat a specification
"col=NA".

Consider:

plot(1:10)
text(4,6,labels="o",col=NA)
points(6,4,col=NA)

The symbol produced by the call to text() shows up (is black).
The symbol produced by the call to points() does not appear.

Of course if one simply does

points(6,4)

then the symbol appears.

This seems to me to be a mild inconsistency.

It is No Big Deal, and in fact doesn't matter at all (who in their
right mind would specify col=NA?).  I only noticed this phenomenon
because of an error I had made in some code.  I'm just curious as to
what is going on.  Is there a reason for the difference in behaviour
between text() and points()?  (And plot(); plot(1:10,col=NA) produces
no points in the plot.)

Note that the help for par() says:

> Some functions such as lines and text accept a vector of values which
> are recycled and may be interpreted slightly differently.

So I guess differences in behaviour are hinted at.

I'm still curious!

Any thoughts from anyone?

cheers,

Rolf Turner

-- 
Honorary Research Fellow
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276



More information about the R-help mailing list