[R] frequency table

Robert Baer rbaer at atsu.edu
Thu Sep 21 22:32:18 CEST 2006



____________________________
Robert W. Baer, Ph.D.
Associate Professor
Department of Physiology
A. T. Still University of Health Science
800 W. Jefferson St. 
Kirksville, MO 63501-1497 USA


----- Original Message ----- > > 

> z = rep(c("M","F"),c(50,60))
>How can I get the following frequency table:
> >
> > Sex             counts     %
> > F                60           54.5
> > M               50           45.5

How about:
data.frame(table(z),percent=100*as.vector(table(z)/sum(table(z))))

HTH,
Rob



More information about the R-help mailing list