format_stats {cocoon} | R Documentation |
Format statistical results
Description
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 tests correlations from the {correlation} package.
-
aov
objects for ANOVAs Bayes factors from the {BayesFactor} package. The function invokes specific methods that depend on the class of the first argument.
Usage
format_stats(x, ...)
Arguments
x |
Statistical object. |
... |
Additional arguments passed to methods. For method-specific
arguments, see |
Value
A character string of statistical information formatted in Markdown or LaTeX.
See Also
Other functions for printing statistical objects:
format_bf()
,
format_corr()
,
format_stats.BFBayesFactor()
,
format_stats.aov()
,
format_stats.easycorrelation()
,
format_stats.htest()
,
format_stats.lm()
,
format_stats.lmerModLmerTest()
,
format_stats.merMod()
,
format_ttest()
Examples
# Format cor.test() object
format_stats(cor.test(mtcars$mpg, mtcars$cyl))
# Format correlation::correlation() object
format_stats(correlation::correlation(data = mtcars, select = "mpg", select2 = "cyl"))
# Format t.test() object
format_stats(t.test(mtcars$vs, mtcars$am))
# Format aov() object
format_stats(aov(mpg ~ cyl * hp, data = mtcars), term = "cyl")
# Format lm() or glm() object
format_stats(lm(mpg ~ cyl * hp, data = mtcars), term = "cyl")
format_stats(glm(am ~ cyl * hp, data = mtcars, family = binomial), term = "cyl")
# Format lme4::lmer() or lme4::glmer() object
format_stats(lme4::lmer(mpg ~ hp + (1 | cyl), data = mtcars), term = "hp")
format_stats(lme4::glmer(am ~ hp + (1 | cyl), data = mtcars, family = binomial), term = "hp")
# Format lmerTest::lmer() object
format_stats(lmerTest::lmer(mpg ~ hp + (1 | cyl), data = mtcars), term = "hp")
# Format BFBayesFactor object from {BayesFactor} package
format_stats(BayesFactor::ttestBF(mtcars$vs, mtcars$am))