Dear Fellow Rers,

I have a table looks like this:

ca, la, 12
ca, sd, 22
ca, la, 33
nm, al, 9
ma, lx, 18
ma, bs, 90
ma, lx, 22

I want to sum the 3rd column grouped by the first and
the second column, so the result look like this table:

ca, la, 45 <
ca, sd, 22
nm, al, 9
ma, lx, 40 <
ma, bs, 90

The two rows with < are sums.

I tried
aggregate(table,list(table$V1,table$V2),sum/mean), sum
was not working while mean worked.

Can anybody give a hint?

Thanks.
Guanrao

______________________________________________
R-help@stat.math.ethz.ch 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.

Reply via email to