print_chi2 | R Documentation |
Print the results of a chi-square test
print_chi2(
x,
es = TRUE,
correct = FALSE,
decimals = 2,
decimals_p = 3,
italic_greek = TRUE
)
x |
A contingency table (passed as |
es |
Boolean. Should the phi coefficient be printed as a measure of effect size. See details. |
correct |
Boolean. Apply a continuity correction? See
|
decimals |
How many decimals should be printed |
decimals_p |
How many decimals should be printed for the p-value (defaults to 3) |
italic_greek |
Should the greek letters (for chi and possily phi)
be printed in italic font. Defaults to |
The argument es
only has an effect if x
is passed as a 2x2
contingency table. In this case, the phi coefficient is computed as
a measure of effect size (see Cohen, 1988, page 223).
According to APA style, the Greek chi symbol (and the phi coefficient) should
be printed in non-italic font. However, the standard symbols
\chi and \phi are written in italic. To print non-italic symbols, use the argument
italic_greek = FALSE
. However, this option requires that you load the Latex
package upgreek
in the YAML header of your R markdown document. To this end,
use the following option in your YAML header:
header-includes: -\usepackage{upgreek}
This option only works for Latex/PDF output.
A string describing the results of the chi-square test to be printed in Rmarkdown documents.
Martin Papenberg martin.papenberg@hhu.de
Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd ed.). Hillsale, NJ: Lawrence Erlbaum.
# Pass a matrix
x <- matrix(c(12, 5, 7, 7), ncol = 2)
print_chi2(x) # does not use continuity correction by default
print_chi2(x, correct = TRUE) # uses continuity correction
# Pass a table
tab <- table(rbinom(150, 1, 0.5), rbinom(150, 1, 0.1))
print_chi2(tab, correct = FALSE)
# Pass a chi-squared test object
print_chi2(chisq.test(tab, correct = FALSE))
# Use non italic chi symbol
print_chi2(tab, italic_greek = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.