tab_pct {tabxplor} | R Documentation |
Add percentages and diffs to a tab
Description
Add percentages and diffs to a tab
Usage
tab_pct(
tabs,
pct = "row",
digits = NULL,
diff = c("tot", "first", "no"),
comp = NULL,
color = FALSE,
just_diff = FALSE
)
Arguments
tabs |
A tibble of class tab made with tab_plain or
tab_many .
|
pct |
The type of percentages to calculate. "row" draw row percentages.
Set to "col" for column percentages. Set to "all" for frequencies
(based on each subtable/group if tab_vars is provided).
Set to "all_tabs" to calculate frequencies based on the whole (set of) table(s).
|
digits |
The number of digits to print for percentages. As a single integer,
or an integer vector the same length than col_vars .
|
diff |
By default, with pct = "row" , differences from total rows are
calculated, and with pct = "col" differences from total columns.
Set to diff = "first" to calculate differences with the first cell
of the row/col (useful to color temporal developments). When not using diffs for colors,
set to diff = "no" to gain calculation time. Diffs are also calculated for
mean columns (made from numeric variables).
|
comp |
Comparison level. When tab_vars are present, should the row
differences be calculated for each subtable/group (by default comp = "tab" :
comparison of each cell to the relative total row) ?
Should they be calculated for the whole table (comp = "all" :
comparison of each cell to the total row of the total table) ?
When comp = "all" and diff = "first" , cells are compared to the first
cell of the total table instead.
This parameter doesn't affect column percentages.
comp must be set once and for all the first time you use tab_chi2 ,
tab_pct with rows, or tab_ci .
|
color |
Set to TRUE to color the resulting tab based on differences (from
totals or from the first cell).
|
just_diff |
If percentages are already calculated and you just want
to recalculate differences.
|
Value
A tibble
of class tab
, with percentages displayed, possibly
colored based on differences from totals or first cell.
[Package
tabxplor version 1.1.3
Index]