Easy statistics with Kable
Created: 2016-10-20
; Updated: 2016-10-20
Let’s say I have a big data frame with columns for age and gender, and I want to quickly summarize the information.
Here’s a simple way to make a pretty summary table:
knitr::kable(with(g3.all,
prop.table(table(gender,cut(age,seq(0,75,by=15))))*100),
digits=2)
Here is a table:
| (0,15] | (15,30] | (30,45] | (45,60] | (60,75] | |
|---|---|---|---|---|---|
| 0.00 | 0.00 | 0.00 | 0.00 | 0.00 | |
| Female | 0.71 | 9.01 | 17.62 | 13.39 | 6.66 |
| Male | 1.06 | 11.31 | 23.47 | 11.35 | 4.77 |
| None | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| Other | 0.00 | 0.06 | 0.22 | 0.17 | 0.10 |
| Select | 0.00 | 0.00 | 0.00 | 0.00 | 0.00 |
| Transgender | 0.00 | 0.04 | 0.06 | 0.00 | 0.00 |