Skip to content

Column sums from a data frame (without the column headers)

2 messages · Jason Horn, jim holtman

#
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!
#
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html and provide commented,
minimal, self-contained, reproducible code.

Here is an example; I am not sure what problem you are having with
'indexing' since you did not show an example.
a   b   c
 55 255 455
a
55
a
55

        
On Fri, Feb 29, 2008 at 2:21 PM, Jason Horn <jhorn at bu.edu> wrote: