[R] frequency table

From: lamack lamack <lamac_k_at_hotmail.com>
Date: Thu 21 Sep 2006 - 15:15:02 GMT

Dear all, I have a vector like this:

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

I try:

DD<- function(data,...)

    n       <-  nobs(data)
    out     <-  c(Frequency  = n,
                  k = n/length(data))


mApply(z,z,DD) but ....

Best regards

Insta-le agora o Windows Live Messenger

R-help@stat.math.ethz.ch 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 Fri Sep 22 01:31:54 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 21 Sep 2006 - 19:30:11 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.