[R] stuff I used to do in Matlab

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Fri Sep 14 09:50:59 CEST 2001


"Timothy Bock" <T.Bock at econ.usyd.edu.au> writes:

> > 	I'm new to R, and trying to map stuff I knew how to do in Matlab
> > to R. For instances, in matlab, sum(x) gave the column sums of
> > matrix(/vector) x. 
> 
> 
> #column sums
> margin.table(x,2)
> # or
> apply(z,2,sum)

Margin.table() is really intended for tables, It was originally a
straight call to apply() but nowadays it is jumping through a
couple of extra hoops to make sure the result is a table (in
particular, it returns a 1D-array instead of a vector for a 1D
marginal). For ordinary matrix operations, it should probably be
avoided. 

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