[R] apply()

Chuck Cleland clelancm at UMDNJ.EDU
Fri Mar 16 14:33:52 CET 2001


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 argument

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



More information about the R-help mailing list