From J.C.Rougier@durham.ac.uk  Fri Nov 10 15:59:40 2000
From: J.C.Rougier@durham.ac.uk (Jonathan Rougier)
Date: Fri, 10 Nov 2000 15:59:40 +0000 (GMT)
Subject: [Rd] Modification to cov and cor
In-Reply-To: <x2n1f7g6yf.fsf@blueberry.kubism.ku.dk>
Message-ID: <Pine.GSO.4.20.0011101556040.8632-100000@laplace>

On 10 Nov 2000, Peter Dalgaard BSA wrote:

> Jonathan Rougier <J.C.Rougier@durham.ac.uk> writes:
> 
> > Can I suggest that in cov and cor the lines
> > 
> >     if (is.data.frame(x)) 
> >         x <- as.matrix(x)
> >     if (is.data.frame(y)) 
> >         y <- as.matrix(y)
> > 
> > be replaced by 
> > 
> >     if (is.data.frame(x)) 
> >         x <- data.matrix(x) # coerce logical and factors
> >     if (is.data.frame(y)) 
> >         y <- data.matrix(y) # likewise
> 
> I'd oppose that, especially for factors. Correlations between factors
> are as likely to be nonsens as remotely meaningful.  

I agree with that.  I was thinking that a warning would be
helpful.  Perhaps something along the lines of

if (any(sapply(x, is.factor))) warning("Coercing factor to numeric")

J.

Jonathan Rougier                       Science Laboratories
Department of Mathematical Sciences    South Road
University of Durham                   Durham DH1 3LE
http://www.maths.dur.ac.uk/stats/people/jcr/jcr.html


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] Modification to cov and cor
Jonathan Rougier