From p.dalgaard@biostat.ku.dk  Fri Nov 10 15:52:40 2000
From: p.dalgaard@biostat.ku.dk (Peter Dalgaard BSA)
Date: 10 Nov 2000 16:52:40 +0100
Subject: [Rd] Modification to cov and cor
In-Reply-To: Jonathan Rougier's message of "Fri, 10 Nov 2000 15:33:51 +0000 (GMT)"
References: <Pine.GSO.4.20.0011101506480.8632-100000@laplace>
Message-ID: <x2n1f7g6yf.fsf@blueberry.kubism.ku.dk>

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.  

With the current definition of data.matrix (using codes(f)), even more so:

> data.matrix(data.frame(a=1:3,b=factor(c("mild","medium","severe"))))
  a b
1 1 2
2 2 1
3 3 3

!!

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
Peter Dalgaard BSA