Skip to content
Prev 1865 / 63421 Next

plot.formula and pch= (PR#149)

I'm not sure exactly where to point my finger with this one, but there
is a nasty surprise to the unsuspecting user.

There is no check on the length of the vector passed in the pch=
argument to plot, it is just recycled as necessary:

plot(1:10,1:10,pch=1:2)

gives alternating circles and triangles. 

The nasty bits come up especially with plot.formula:

x<-1:10;y<-1:10 
plot(y~x,subset=x%%2==1,pch=x%%2)

- and the plotting symbols are *not* all the same. Even more
  pernicious, if missing values are involved:
gives you the wrong symbols (in practice, this messes up things like 
plot(height~age,pch=sex) rather badly!).

It would help to get a warning that the lengths don't match, but are
there any good uses of the recycling of pch?