tab_plain | R Documentation |
Plain single cross-table
tab_plain(
data,
row_var,
col_var,
tab_vars,
wt,
pct = "no",
color = "no",
OR = "no",
na = "keep",
ref = "auto",
ref2 = "first",
comp = "tab",
totaltab = "line",
totaltab_name = "Ensemble",
tot = NULL,
total_names = "Total",
subtext = "",
digits = 0,
num = FALSE,
df = FALSE
)
data |
A data frame. |
row_var , col_var |
The row variable, which will be printed with one level per line,
and the column variable, which will be printed with one level per column. Numeric
variables will be used as factors. To calculate means, use |
tab_vars |
<tidy-select> Tab variables : a subtable is made for each combination of levels of the selected variables. Leave empty to make a simple cross-table. All tab variables are converted to factor. |
wt |
A weight variable, of class numeric. Leave empty for unweighted results. |
pct |
The type of percentages to calculate :
|
color |
The type of colors to print, as a single string :
|
OR |
With
|
na |
The policy to adopt with missing values, as a single string.
|
ref |
The reference cell to calculate differences and ratios
(used to print
|
ref2 |
A second reference cell is needed to calculate odds ratios
(or relative risks ratios). The first cell of the row or column is used by default.
See |
comp |
Comparison level. When |
totaltab |
The total table,
if there are subtables/groups (i.e. when
|
totaltab_name |
The name of the total table, as a single string. |
tot |
The totals :
|
total_names |
The names of the totals, as a character vector of length one or two.
Use syntax of type |
subtext |
A character vector to print rows of legend under the table. |
digits |
The number of digits to print, as a single integer. |
num |
Set to |
df |
Set to |
A tibble
of class tabxplor_tab
. If ...
(tab_vars
)
are provided, a tab
of class tabxplor_grouped_tab
.
All non-text columns are fmt
vectors of class tabxplor_fmt
,
storing all the data necessary to print formats and colors. Columns with row_var
and tab_vars
are of class factor
: every added factor
will be
considered as a tab_vars
and used for grouping. To add text columns without
using them in calculations, be sure they are of class character
.
# A typical workflow with tabxplor step-by-step functions :
data <- dplyr::starwars %>% tab_prepare(sex, hair_color)
data %>%
tab_plain(sex, hair_color, tot = c("row", "col"), pct = "row") %>%
tab_chi2() %>%
tab_ci(color = "after_ci")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.