[R] Dummy newbie question
ripley@stats.ox.ac.uk
ripley at stats.ox.ac.uk
Wed Apr 24 10:07:30 CEST 2002
On Wed, 24 Apr 2002, Julien Barnier wrote:
> 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.
A data frame or a matrix? You can only do this for data frames all of
whose columns are numeric, or for numeric matrices. Suppose A is either
sort of object:
apply(A, 1, sum) # row sums
apply(A, 2, sum) # columns sums
As from next week's R 1.5.0 you will be able to use rowSums(A) and
colSums(A).
> There is surely a very simple way to do that, but I didn't find it...
Not `very simple' until next week.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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