Library "tables" and tabular function is neato. 

 

I'm trying to figure out how to get percents other than just row and
columns. I'd like a percent of a factor.  

 

 

library(tables)

 

c=data.frame(

      gender=c(1,1,1,1,2,2,2,2),

      race=c(3,3,4,4,4,4,4,4)

)

tabular(

      Factor(gender,"Gender") * 

      Factor(race, "Race") + 1 ~

      (n=1) + Percent("col"),

      data=c

)

 

 

The above produces:

 

Gender Race n Percent

1      3    2  25    

        4    2  25    

 2      3    0   0    

        4    4  50    

        All  8 100    

> 

 

 

I'm looking for percents to have gender=1 or gender=2 as the denominator.
I.e.,

 

 

 

Gender Race n Percent

1      3    2  *50*    

        4    2  *50*    

 2      3    0   *0*    

        4    4  *100*  

        All  8 100    

> 

 

 

 

 

Daniel Cher, MD

 <mailto:djcher@gmail.com> djcher@gmail.com

+1-650-269-5763

 

This message and its attachments are confidential.\ \  \...{{dropped:8}}

