[R] Frequency table

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Mar 17 17:12:06 CET 2004


On 17 Mar 2004, Peter Dalgaard wrote:

> Kai Hendry <hendry at cs.helsinki.fi> writes:
> 
> 
> > 40-49   2
> > 50-59   15
> > 60-69   20
> > 70-79   19
> > 80-89   12
> > 90-99   2
> 
> Here's another solution for this 10-year age group thing:
> 
> tt<-table(zz%/%10)
> n <- names(tt)
> names(tt) <- paste(n,0,"-",n,9,sep="")
> tt
> data.frame(count=c(tt))
> 
> Beware that empty groups are silently zapped, though.

FWIW, table(factor(zz%/%10, levels=0:9))  avoids that

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list