Dear R/S users; I'm using S+ version 4 Release 3. 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> W1VAR00003 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? Many thanks in advance. Mehdi __________________________________________________ Do You Yahoo!? Send instant messages & get email alerts with Yahoo! Messenger. http://im.yahoo.com/ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Mehdi Ghafariyan schrieb: [...]> > 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?I guess the problem is you extracted W1 from a dataframe. Try this:> W1 <- as.matrix(W[1:5,1:5]) > S1 <- (t(X1 - Xbar1)) %*% W1 %*% (X1 - Xbar1)Jan Seidel -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Hi all; Thanks to those R users ,who kindly helped me with the problem; W1 should have been defined as a matrix which some people mentioned and as.matrix(W1) would do the job. cheers Mehdi> > ---------- > > From: Mehdi > Ghafariyan[SMTP:mehdi_ghafariyan at yahoo.com] > > Sent: Tuesday, September 19, 2000 6:10 AM > > To: r-help at stat.math.ethz.ch > > Subject: [R] coerce mode list? > > > > Dear R/S users; > > I'm using S+ version 4 Release 3. > > 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? > > > > Many thanks in advance. > > Mehdi > > > > > > > > > > __________________________________________________ > > Do You Yahoo!? > > Send instant messages & get email alerts with > Yahoo! Messenger. > > http://im.yahoo.com/ > > >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.> > -.-.- > > 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 > > >_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.> > _._._ > >__________________________________________________ Do You Yahoo!? Send instant messages & get email alerts with Yahoo! Messenger. http://im.yahoo.com/ -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._