knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
The goal of statstring is to facilitate formatting outputs of statistical tests when they're pasted into R markdown files in APA style. Currently, statstring can format results of ANOVA outputs generated by stats::aov()
, summary(stats::aov)
, rstatix::get_anova_table()
, and apaTables::apa.aov.table()
. To format the outputs for R markdown, simply pass one of the previously listed ANVOA objects to the function format_anova_string()
.
The package can also handle outputs from an independent samples t-test, generated by stats::t.test()
. The formatted output includes the mean difference and a 95% confidence interval (CI) on the mean difference.
You can also use the package to extract and format R^2^ for a model produced by stats::lm()
or summary(stats::lm())
using the function format_r2()
.
Finally, you can use this package to format point estimates and 95% CI around the point estimate using format_confint()
.
You can install the released version of statstring from Github with: devtools::install_github("silverer/statstring")
This is a basic example which shows you how to solve a common problem:
library(statstring) data("warpbreaks") #Results of a t-test t.res = stats::t.test(breaks~wool, data = warpbreaks, var.equal=T) t.res t.str = format_tstat_apa(t.res) #Results of ANOVA aov.res = stats::aov(breaks~wool*tension, data = warpbreaks) summary(aov.res) #Getting all F-statistics all.aov.results = format_anova_string(summary(aov.res)) #Results of linear model lm.res = stats::lm(breaks~ wool + tension, data = warpbreaks) summary(lm.res) r2 = format_r2(lm.res)
For the t-test, the output looks like r t.str
.
For ANOVAs, the output corresponds to the order in which terms were entered into the model. For example, the term for wool (the first factor in the model) is: r all.aov.results[1]
, for tension is r all.aov.results[2]
, and for the interaction between tension and wool: r all.aov.results[3]
For a linear model using breaks as the criterion and wool and tension as predictors, r r2
You can also get formatted text outputs that do not include the special characters used for formatting things in markdown, such as the underscore for italics. To turn off markdown formatting, pass the argument as.markdown=F
to your function.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.