Calculate and add a p-value comparing the two variables in the cross table. Missing values are included in p-value calculations.
# S3 method for tbl_cross
add_p(
x,
test = NULL,
pvalue_fun = NULL,
source_note = NULL,
test.args = NULL,
...
)
Object with class tbl_cross
from the tbl_cross function
A string specifying statistical test to perform. Default is
"chisq.test
" when expected cell counts >=5 and "fisher.test
" when
expected cell counts <5.
Function to round and format p-value.
Default is style_pvalue, except when source_note = TRUE
when the
default is style_pvalue(x, prepend_p = TRUE)
Logical value indicating whether to show p-value in the {gt} table source notes rather than a column.
Named list containing additional arguments to pass to
the test (if it accepts additional arguments).
For example, add an argument for a chi-squared test with
test.args = list(correct = TRUE)
Not used
Example 1
Example 2
Other tbl_cross tools:
inline_text.tbl_cross()
,
tbl_cross()