Re: [R] using table and tapply?

From: Charles C. Berry <cberry_at_tajo.ucsd.edu>
Date: Mon, 21 Jun 2010 09:14:12 -0700

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

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 - 16:16:34 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 - 16:50:33 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