[R] Frequency and summary statistics table with different variables and categories

2009-01-22 Thread Stefan Björk
Hello helpers, This is probably quite simple, but I'm stuck. I want to create a summary statistics table with frequencies and summary statistics for a large number of variables. The problem here is that (1) there are two different classes of categories (sex, type of substance abuse and type of

Re: [R] Frequency and summary statistics table with different variables and categories

2009-01-22 Thread ronggui
Since %male is basically the mean if you code male=1 and female=0, which is more informative than absolute frequency. So, you may want to have a glance at doBy package, especially the summaryBy function. All the best On Thu, Jan 22, 2009 at 7:17 PM, Stefan Björk stefan.bj...@gmail.com wrote:

Re: [R] Frequency and summary statistics table with different variables and categories

2009-01-22 Thread David Winsemius
One of the various tabulation functions would seem to be the most appropriate for getting frequency summaries: ?table ?xtabs On Jan 22, 2009, at 6:17 AM, Stefan Björk wrote: Hello helpers, This is probably quite simple, but I'm stuck. I want to create a summary statistics table with

Re: [R] Frequency and summary statistics table with different variables and categories

2009-01-22 Thread David Winsemius
You should look at how summary.data.frame does it. (You are, of course, re-inventing the wheel.) You probably ought to also look at the doBy package with its summaryBy function. The help page example uses the length function for counts. I often prefer the output of describe() in Hmisc. --