[R] using table and tapply?
Charles C. Berry
cberry at tajo.ucsd.edu
Mon Jun 21 18:14:12 CEST 2010
On Sun, 20 Jun 2010, Erin Hodgess wrote:
> 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.
Like this?
> xtabs(DEATH1~Co,dat)
Co
Botulinic Constitutional Gastrointestinal Other
23 106 30 85
If not, please say what the result should be.
HTH,
Chuck
>
>
> 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
>
> ______________________________________________
> 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.
>
Charles C. Berry (858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
More information about the R-help
mailing list