[Rd] Small change to plot.xy

Jonathan Rougier J.C.Rougier@durham.ac.uk
Fri, 22 Nov 2002 12:31:07 +0000


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