[R] Hmisc::rcorr on a 'data.frame'?

Liviu Andronic landronimirc at gmail.com
Fri Aug 19 20:40:53 CEST 2011


Dear all
?Hmisc::rcorr states that it takes as main argument "a numeric
matrix". But is it normal that it fails in such an ugly way on a data
frame? (See below.) If the function didn't attempt any conversion to a
matrix, I would have expected it to state that in the error message
that it didn't accept 'data.frame' objects in its input. Also, I
vaguely remember having used in the past rcorr() on data frames.

Regards
Liviu

> require(Hmisc)
> rcorr(mtcars[ , 1:4])
Error in storage.mode(x) <- if (.R.) "double" else "single" :
  (list) object cannot be coerced to type 'double'
> rcorr(as.matrix(mtcars[ , 1:4]))
       mpg   cyl  disp    hp
mpg   1.00 -0.85 -0.85 -0.78
cyl  -0.85  1.00  0.90  0.83
disp -0.85  0.90  1.00  0.79
hp   -0.78  0.83  0.79  1.00

n= 32


P
     mpg cyl disp hp
mpg       0   0    0
cyl   0       0    0
disp  0   0        0
hp    0   0   0




-- 
Do you know how to read?
http://www.alienetworks.com/srtest.cfm
http://goodies.xfce.org/projects/applications/xfce4-dict#speed-reader
Do you know how to write?
http://garbl.home.comcast.net/~garbl/stylemanual/e.htm#e-mail



More information about the R-help mailing list