[R] using table and tapply? solved

From: Erin Hodgess <erinm.hodgess_at_gmail.com>
Date: Sun, 20 Jun 2010 21:32:00 -0500


Here is my solution:

tapply(zzz$DEATH1,zzz$GENDER,sum, na.rm=TRUE)

Dear R People:

Here is a little section of a data frame:

> zzz[1:10,]

           DATE GENDER AGE               Co DEATH1
3945  2009-04-16      M  24        Botulinic     23
3851  2009-04-16      M  35   Constitutional     23
8495  2009-04-16      F  49   Constitutional     27
10967 2009-04-16      F  47   Constitutional     28
11164 2009-04-16      F  26   Constitutional     28
15220 2009-04-16      M  49 Gastrointestinal     30
1207  2009-04-16      F  39            Other     20
1514  2009-04-16      F  39            Other     20
2548  2009-04-16      M  49            Other     22
3430  2009-04-16      F  54            Other     23

>

sometimes I want use the date and obtain the totals deaths, sometimes I want to use the Co and obtain the total number of deaths, etc.

I've tried "table" and "with" but am having no success.

Any help would be much appreciated.

thanks,
Erin

--
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodgess_at_gmail.com

-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: erinm.hodgess_at_gmail.com

______________________________________________
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 Mon 21 Jun 2010 - 02:35:04 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 Mon 21 Jun 2010 - 03:50:34 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