This method formats analysis of variance (ANOVA) statistics from the class
aov
. The default output is APA formatted, but this function allows control
over numbers of digits, leading zeros, italics, degrees of freedom,
and output format of Markdown or LaTeX.
Usage
# S3 method for class 'aov'
format_stats(
x,
term,
digits = 1,
pdigits = 3,
pzero = FALSE,
italics = TRUE,
dfs = "par",
type = "md",
...
)
Arguments
- x
An
aov
object fromstats::aov()
.- term
Character string for row name of term to extract statistics for. This must be the exact string returned in the
summary()
output from theaov
object.- digits
Number of digits after the decimal for means, confidence intervals, and test statistics.
- pdigits
Number of digits after the decimal for p-values, ranging between 1-5 (also controls cutoff for small p-values).
- pzero
Logical value (default = FALSE) for whether to include leading zero for p-values.
- italics
Logical value (default = TRUE) for whether p label should be italicized.
- dfs
Formatting for degrees of freedom ("par" = parenthetical, "sub" = subscript, "none" = do not print degrees of freedom).
- type
Type of formatting ("md" = markdown, "latex" = LaTeX).
- ...
Additional arguments passed to methods.
See also
Other functions for printing statistical objects:
format_bf()
,
format_corr()
,
format_stats()
,
format_stats.BFBayesFactor()
,
format_stats.easycorrelation()
,
format_stats.htest()
,
format_stats.lm()
,
format_stats.lmerModLmerTest()
,
format_stats.merMod()
,
format_ttest()
Examples
test_aov <- aov(mpg ~ cyl * hp, data = mtcars)
# Format ANOVA
format_stats(test_aov, term = "cyl")
#> [1] "_F_(1, 28) = 92.5, _p_ < .001"
# Remove italics and make degrees of freedom subscripts
format_stats(test_aov, term = "cyl", italics = FALSE, dfs = "sub")
#> [1] "F~1,28~ = 92.5, p < .001"
# Change digits and add leading zero to p-value
format_stats(test_aov, term = "hp", digits = 3, pdigits = 4, pzero = TRUE)
#> [1] "_F_(1, 28) = 1.850, _p_ = 0.1846"
# Format for LaTeX
format_stats(test_aov, term = "hp", type = "latex")
#> [1] "$F$(1, 28) = 1.9, $p$ = .185"