From J.C.Rougier@durham.ac.uk  Fri Nov 22 12:31:07 2002
From: J.C.Rougier@durham.ac.uk (Jonathan Rougier)
Date: Fri, 22 Nov 2002 12:31:07 +0000
Subject: [Rd] Small change to plot.xy
Message-ID: <3DDE238B.FDC95BDB@durham.ac.uk>

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



[Rd] Small change to plot.xy
Jonathan Rougier