Re: [R] Percentages for categorical data by group

From: Economics Guy <>
Date: Fri, 23 May 2008 13:31:45 -0400

Thanks Michael that works!

Now I am having a problem getting the results into a format I can use.

prop.table generates a contingency table that I tried to turn into a data frame I could graph from with however the results are not a true data.frame. The rows have commas between some of the elements and trying to look at a column results in the original contingency table being displayed.

This is what I have:

pop <- matrix(1:100000)
groupIDs <- sample(pop,500)
groupVar <- sample(groupIDs,23000,replace=TRUE) responseVar <- sample(1:5,23000,replace=TRUE) <- data.frame(groupVar,responseVar)

data.table <-
tapply($responseVar,$groupVar,function(x){prop.table(table(x))}) <-

But the object is not a true data frame, and I am not sure how to get it into a format I can graph.

On Fri, May 23, 2008 at 11:33 AM, Michael Conklin <> wrote:

> tapply($responseVar,$groupVar,function(x){prop.t
> able(table(x))})
> Michael Conklin
> Chief Methodologist - Advanced Analytics

        [[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:17:17 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 - 18:30:43 GMT.

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

list of date sections of archive