[R] Dummy newbie question
Uwe Ligges
ligges at statistik.uni-dortmund.de
Wed Apr 24 10:07:07 CEST 2002
Julien Barnier wrote:
>
> Hi,
>
> Excuse me for a so dummy question, but I really can't manage to do this
> very simple thing : I have a data frame, and I would like to calculate
> two vectors which contain the sums respectively of the rows and of the
> columns of the matrix.
>
> There is surely a very simple way to do that, but I didn't find it...
In R <= 1.4.1:
apply(x, 1, sum)
apply(x, 2, sum)
In R >= 1.5.0 (in development):
colSums(x)
rowSums(x)
Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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