All functions in this package are deprecated. Please use the
{cocoon}
package instead.
With format_ttest()
you can format t-tests generated from t.test()
and
wilcox.test()
output. The default output is APA formatted, but numbers of
digits, leading zeros, the presence of means and confidence intervals,
italics, degrees of freedom, and mean labels are all customizable.
Usage
format_ttest(
x,
digits = 1,
pdigits = 3,
pzero = FALSE,
full = TRUE,
italics = TRUE,
dfs = "par",
mean = "abbr",
type = "md"
)
Arguments
- x
t-test object
- digits
Number of digits after the decimal for means, confidence intervals, and t-statistics
- pdigits
Number of digits after the decimal for p-values, ranging between 1-5 (also controls cutoff for small p-values)
- pzero
Logical indicator of whether to include leading zero for p-values
- full
Logical indicator of whether to include means and confidence intervals or just t-statistic and p-value
- italics
Logical for whether p label should be italicized
- dfs
Formatting for degrees of freedom ("par" = parenthetical, "sub" = subscript, "none" = do not print degrees of freedom)
- mean
Formatting for mean label ("abbr" = M, "word" = Mean)
- type
Type of formatting ("md" = markdown, "latex" = LaTeX)
Examples
# Prepare data
mtcars_tt <- t.test(formula = mtcars$mpg ~ mtcars$vs)
# Print statistics
format_ttest(mtcars_tt)
#> Warning: `format_ttest()` was deprecated in formatstats 0.0.0.9000.
#> ℹ Please use `cocoon::format_ttest()` instead.
#> [1] "_M_ = -7.9, 95% CI [-11.5, -4.4], _t_(22.7) = -4.7, _p_ < .001"
# Change digits
format_ttest(mtcars_tt, digits = 2)
#> [1] "_M_ = -7.94, 95% CI [-11.46, -4.42], _t_(22.72) = -4.67, _p_ < .001"
# Change cutoff digits for p-value
format_ttest(mtcars_tt, pdigits = 2)
#> [1] "_M_ = -7.9, 95% CI [-11.5, -4.4], _t_(22.7) = -4.7, _p_ < .01"
# Add leading zero to p-value and don't print confidence intervals
format_ttest(mtcars_tt, pzero = TRUE, full = FALSE)
#> [1] "_t_(22.7) = -4.7, _p_ < 0.001"