prettytable | R Documentation |
Automatically append relative proportions/percentages to raw counts calculated from table()
. Currently only works for 1 and 2 way frequency tables.
prettytable(mytable, margin = 1)
margin |
Defaults to 1, calculate row-wise proportions. Change to 2 to calculate column-wise proportions. |
table |
A table object from |
Returns a table with relative proportions/percentages appended to raw counts.
mydata <- data.frame(x1 = rep(c("Male","Female","Male"), 100), x2 = rep(c("High","Medium","Low"),100))
# two way frequency table
a <- table(mydata$x1,mydata$x2)
prettytable(a)
# feed it into kable for a prettier table
knitr::kable(prettytable(a), align = "c")
# one way frequency table
a <- table(mydata$x1)
prettytable(a)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.