tbl | R Documentation |
This function creates a contingency table from two specified variables in a dataset, with optional grouping, statistical calculations, and formatting.
tbl(
data,
v1,
v2,
groups = NULL,
margin = "all",
stat = "both",
total = c("row", "col"),
use.labels = T,
digits = 1,
na.label = "NA"
)
data |
A data frame containing the data to be analyzed. |
v1 |
The first variable for the contingency table. No need to be quoted. |
v2 |
The second variable for the contingency table. No need to be quoted. |
groups |
Optional grouping variable of vector of variables. No need to be quoted. |
margin |
Specifies the margin for proportions ('all', 'row', or 'col'). |
stat |
The type of statistic to calculate: "n" for counts, "perc" for percentages, or "both" for both. |
total |
Specifies whether to include totals for rows or columns ("row", "col"). |
use.labels |
Logical; should labels from the data be used? |
digits |
The number of digits to display for percentages. |
na.label |
The label to use for NA values. |
A printed table of counts and/or proportions as specified, with totals where applicable.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.