Re: [R] Column sums from a data frame (without the headers)

From: Gabor Csardi <csardi_at_rmki.kfki.hu>
Date: Fri, 29 Feb 2008 18:10:53 +0100

colSums gives you exactly what you want, but the vector is *named*. You can use it like a not-named numeric vector, without much trouble. If you still want to get rid of the names see ?unname

G.

On Fri, Feb 29, 2008 at 12:02:46PM -0500, Jason Horn wrote:
> Does anyone know how to get a vector of column sum from a data frame?
> You can use colSums(), but this gives you a object of type "numeric"
> with the column labels in the first row, and the sums in the second
> row. I just want a vector of the sums, and I can't figure out a way
> to index the "numeric" object.
>
> Thanks!
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Csardi Gabor <csardi_at_rmki.kfki.hu>    UNIL DGM

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Fri 29 Feb 2008 - 17:13:12 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 29 Feb 2008 - 17:30:18 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive