Hi, I input this command on a data matrix: > apply( traffic, 2, function(z){z-mean(z)}) and got the following error messages: Error in sum(..., na.rm = na.rm) : invalid "mode" of argument Can anyone tell me what is wrong here? Running R1.2.2 on Windows ME. Cheers, Kevin ------------------------------------------------- Ko-Kang Kevin Wang Statistical Analysis Division Leader Software Developers' Klub University of Auckland New Zealand -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Friday 16 March 2001 09:55, Ko-Kang at xtra.co.nz wrote:> Hi, > > I input this command on a data matrix: > > apply( traffic, 2, function(z){z-mean(z)}) > > and got the following error messages: > Error in sum(..., na.rm = na.rm) : invalid "mode" of argument > > Can anyone tell me what is wrong here?Is it really a normal matrix? Because the following works here: m <- matrix(rnorm(100), nrow=10) apply(m,2,function(z){z-mean(z)}) (R 1.2.2 on Linux) Cheers Kaspar P.S: Please refrain from sending HTML mails. Your message was all but unreadable on my screen because I haven't the required font and my mail client does not (yet) filter HTML to text -- Kaspar Pflugshaupt Geobotanical Institute ETH Zurich, Switzerland http://www.geobot.umnw.ethz.ch mailto:pflugshaupt at geobot.umnw.ethz.ch -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Ko-Kang at xtra.co.nz wrote:> I input this command on a data matrix: > > apply( traffic, 2, function(z){z-mean(z)}) > > and got the following error messages: > Error in sum(..., na.rm = na.rm) : invalid "mode" of argumentCould be that traffic is not a proper matrix. Are all of the columns of traffic numeric? And why not try this, which should be equivalent and handles NA's better. apply(traffic, 2, scale, scale=F) HTH, Chuck -<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>- Chuck Cleland Institute for the Study of Child Development UMDNJ--Robert Wood Johnson Medical School 97 Paterson Street New Brunswick, NJ 08903 phone: (732) 235-7699 fax: (732) 235-6189 http://www2.umdnj.edu/iscdweb/ http://members.nbci.com/cmcleland/ -<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._