A generic function that takes objects from various statistical methods to create formatted character strings to insert into R Markdown or Quarto documents. Currently, the generic function works with the following objects:
htest
objects of correlations, t-tests, and Wilcoxon testscorrelations from the {correlation} package.
Bayes factors from the {BayesFactor} package. The function invokes specific methods that depend on the class of the first argument.
Arguments
- x
Statistical object.
- ...
Additional arguments passed to methods. For method-specific arguments, see
format_stats.htest()
for htest correlations, t-tests, and Wilcoxon tests andformat_stats.BFBayesFactor()
for Bayes factors from the {BayesFactor} package.
See also
Other functions for printing statistical objects:
format_bf()
,
format_corr()
,
format_stats.BFBayesFactor()
,
format_stats.easycorrelation()
,
format_stats.htest()
,
format_ttest()
Examples
# Format cor.test() object
format_stats(cor.test(mtcars$mpg, mtcars$cyl))
#> [1] "_r_ = -.85, 95% CI [-0.93, -0.72], _p_ < .001"
# Format correlation::correlation() object
format_stats(correlation::correlation(data = mtcars, select = "mpg", select2 = "cyl"))
#> [1] "_r_ = -.85, 95% CI [-0.93, -0.72], _p_ < .001"
# Format t.test() object
format_stats(t.test(mtcars$vs, mtcars$am))
#> [1] "_M_ = 0.0, 95% CI [-0.2, 0.3], _t_(62) = 0.2, _p_ = .804"
# Format BFBayesFactor object from {BayesFactor} package
format_stats(BayesFactor::ttestBF(mtcars$vs, mtcars$am))
#> [1] "_BF_~10~ = 0.26"