prop | R Documentation |
Return the percentages of a two-way frequency table with formatting and printing options.
prop(tab, ...) prop_table( tab, digits = 1, total = TRUE, percent = FALSE, drop = TRUE, n = FALSE, ... ) ## S3 method for class 'data.frame' prop( tab, digits = 1, total = TRUE, percent = FALSE, drop = TRUE, n = FALSE, ... ) ## S3 method for class 'matrix' prop( tab, digits = 1, total = TRUE, percent = FALSE, drop = TRUE, n = FALSE, ... ) ## S3 method for class 'tabyl' prop(tab, digits = 1, total = TRUE, percent = FALSE, n = FALSE, ...)
tab |
frequency table |
... |
parameters passed to other methods |
digits |
number of digits to display |
total |
if |
percent |
if |
drop |
if |
n |
if |
The result is an object of class table
and proptab
.
rprop
, cprop
, table
, prop.table
## Sample table data(Titanic) tab <- apply(Titanic, c(1,4), sum) ## Percentages prop(tab) ## Percentages with custom display prop(tab, digits=2, percent=TRUE, total=FALSE, n=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.