[Rd] Small change to plot.xy
ripley@stats.ox.ac.uk
ripley@stats.ox.ac.uk
Fri, 22 Nov 2002 13:02:32 +0000 (GMT)
*Not* codes! Unclass perhaps.
However, why should col=factor(c("red", "blue", "green"))
not as naturally coerce to character.
I think we do need to get the user to specify what is meant, as now.
There are lots of examples of this sort of thing in MASS, BTW.
On Fri, 22 Nov 2002, Jonathan Rougier wrote:
> Hi everyone,
>
> Is there any reason why we should not automatically coerce a factor
> supplied as an argument to col in a plotting function? The following
> modification (to R-1.6.1) seems pretty harmless
>
> > plot.xy
> function (xy, type, pch = 1, lty = "solid", col = par("fg"),
> bg = NA, cex = 1, ...)
> {
> if (is.factor(col))
> col <- codes(col)
> .Internal(plot.xy(xy, type, pch, lty, col, bg, cex, ...))
> }
> <environment: namespace:base>
>
> and I think it is natural and not really wrong to want to type, say,
>
> > data(iris)
> > pairs(iris[, 1:4], col = iris[, 5])
>
> and get the colours.
>
> Cheers, Jonathan.
>
> --
> Jonathan Rougier Science Laboratories
> Department of Mathematical Sciences South Road
> University of Durham Durham DH1 3LE
> tel: +44 (0)191 374 2361, fax: +44 (0)191 374 7388
> http://www.maths.dur.ac.uk/stats/people/jcr/jcr.html
>
> ______________________________________________
> R-devel@stat.math.ethz.ch mailing list
> http://www.stat.math.ethz.ch/mailman/listinfo/r-devel
>
--
Brian D. Ripley, ripley@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 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595