See

        ?ftable
        ?as.data.frame
        ?xtabs

e.g.

        ftable( xtabs( ~code+year+month, your.df ), col.vars=1 )
        as.data.frame( xtabs(~code+year+month, your.df ) )

HTH,

Chuck

On Tue, 23 Sep 2008, Hutchinson,David [PYR] wrote:

Hi R-Users,

I have a data frame containing year, month, day, and code columns. The
code column is a unique character of set ('E','A','B') - I am trying to
determine an efficient way of summarizing the count of each of these
codes by month and year without having to use for...loops and subsets.
Does anyone have any suggestions?

Thanks in advance,
Dave

Here is a snapshot of my data frame:

    year month day code
8006 1935    12   1    E
8007 1935    12   2
8008 1935    12   3    E
8009 1935    12   4
8010 1935    12   5    E
8011 1935    12   6    E

______________________________________________
R-help@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:[EMAIL PROTECTED]                  UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901

______________________________________________
R-help@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.

Reply via email to