[R] coerce mode list?

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Tue Sep 19 13:34:31 CEST 2000


Mehdi Ghafariyan <mehdi_ghafariyan at yahoo.com> writes:

> Dear R/S users;
> I'm using S+ version 4 Release 3.

Um, now what's wrong with S-news?

> and I am trying to do a simple calculation like the
> following :
> 
> > X1<-X[1:5]
> > W1<-W[1:5,1:5]
> > X1
> [1] 1.250000 1.292308 1.176471 0.937500 1.538462
> > W1
>   VAR00003 VAR00004 VAR00005 VAR00006 VAR00007 
> 1        0        1        0        1        0
> 2        1        0        0        0        1
> 3        0        0        0        0        1
> 4        1        0        0        0        0
> 5        0        1        1        0        0
> > Xbar1 <- mean(X1)
> > S1 <- (t(X1 - Xbar1)) %*% W1 %*% (X1 - Xbar1)
> Error in as.double: Cannot coerce mode list to double:
> .Data = list(..
> Dumped
> > S1 <- (t(as.double(X1 - Xbar1))) %*% W1 %*%
> (as.double(X1 - Xbar1))
> Error in as.double: Cannot coerce mode list to double:
> .Data = list(..
> Dumped
> 
> 
> I don't understand the error message. Can anyone help?

My guess would be that W and hence W1 is a data frame and not a matrix.

-- 
   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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list