Ulrich Leopold <uleopold at science.uva.nl> writes:
> Dear list,
>
> I get the following message when I use rcorr in library "Hmisc"
>
> ------------------------------------------------------
> > rcorr(lskPox0t30, type=c("spearman"))
> Error in "[<-.data.frame"(*tmp*, is.na(x), value = 1e+30) :
> matrix subscripts not allowed in replacement
> ------------------------------------------------------
>
> I do not understand this message. Is it due to that I have missing
> values? Or is it an error in the function rcorr? What's a matrix
> subscript?
I think the upshot is that lskPox0t30 needs to be a matrix, not a data
frame.
A matrix subscript allows you to pick elements from a p dimensional
array by indexing with an n x p matrix, as in
(m <- matrix(1:9,3))
(i <- cbind(1:2,2:3))
m[i]
The thing that happens is the same as
> data(airquality)
> airquality[is.na(airquality)] <- 99999
Error in "[<-.data.frame"(*tmp*, is.na(airquality), value = 99999)
:
matrix subscripts not allowed in replacement
> airquality <- as.matrix(airquality)
> airquality[is.na(airquality)] <- 99999 #works
(The error message is slightly beside the point. is.na(airquality) is
a matrix in both cases, but since it has mode "logical", the
dimensions are ignored.)
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at
stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._