Skip to content
Prev 145154 / 398500 Next

Percentages for categorical data by group

on 05/23/2008 09:51 AM Economics Guy wrote:
Using:

   table(example.data)

will give you a cross tabulation of the counts of your ResponseVar by 
each groupVar.

   prop.table(table(example.data), 1)

will give you a row-wise proportion (0 - 1) of the counts of ResponseVar 
for each groupVar. If you want percentages (0 - 100):

    prop.table(table(example.data), 1) * 100


See ?table and ?prop.table for more information.

HTH,

Marc Schwartz