Re: [R] Percentages for categorical data by group

From: Economics Guy <>
Date: Fri, 23 May 2008 14:35:52 -0400

I appreciate all the help. The trouble is that in my real data set each group does not always have an observation that choose each response. This results in some of the "rows" returned from prop.table() to be shorter than others so I get:

Warning message:
In function (..., deparse.level = 1) :
  number of columns of result is not a multiple of vector length (arg 8)

Is there a way to tell rbind() or to treat missing values as zero or make prop.table() include the zero proportions?

On Fri, May 23, 2008 at 1:59 PM, Phil Spector <> wrote:

> EG -
> Thanks for the reproducible example!
> When I run your code, and check the class of the result from tapply(), I

> see that it is an
> "array", and using dim(), I see it's an array
> of length 500. How big is each element?
> table(sapply(res,length))
> 5
> 500
> So each piece is the same length. That means we could
> make a 500x5 matrix as follows:
> - Phil Spector
> Statistical Computing Facility
> Department of Statistics
> UC Berkeley

        [[alternative HTML version deleted]] mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Fri 23 May 2008 - 18:40:10 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 23 May 2008 - 21:30:41 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive