Creates an expression from a dataframe containing statistical details. Ideally, this dataframe would come from having run tidy_model_parameters function on your model object.

This function is currently not stable and should not be used outside of this package context.

  no.parameters = 0L,
  bayesian = FALSE,
  statistic.text = NULL,
  effsize.text = NULL,
  top.text = NULL,
  prior.distribution = NULL,
  prior.type = NULL,
  n = NULL,
  n.text = NULL,
  paired = FALSE,
  conf.method = "HDI",
  k = 2L,
  k.df = 0L,
  k.df.error = 0L,



A dataframe containing details from the statistical analysis and should contain some or all of the the following columns:

  • statistic: the numeric value of a statistic.

  • df.error: the numeric value of a parameter being modeled (often degrees of freedom for the test); note that if no.parameters = 0L (e.g., for non-parametric tests), this column will be irrelevant.

  • df relevant only if the statistic in question has two degrees of freedom.

  • p.value the two-sided p-value associated with the observed statistic.

  • estimate: estimated value of the effect size.

  • conf.level: width for the confidence intervals.

  • conf.low: lower bound for effect size estimate.

  • conf.high: upper bound for effect size estimate.

  • bf10 Bayes Factor value (if bayesian = TRUE).

  • method: method describing the test carried out.


An integer that specifies that the number of parameters for the statistical test. Can be 0 for non-parametric tests, 1 for tests based on t-statistic or chi-squared statistic, 2 for tests based on F-statistic.


Is this Bayesian analysis? Defaults to FALSE. The template is slightly different for Bayesian analysis.


A character that specifies the relevant test statistic. For example, for tests with t-statistic, statistic.text = "t".


A character that specifies the relevant effect size.


Text to display on top of the Bayes Factor message. This is mostly relevant in the context of ggstatsplot functions.


A character that specifies the prior type.


The type of prior.


An integer specifying the sample size used for the test.


A character that specifies the design, which will determine what the n stands for. If NULL, defaults to quote(italic("n")["pairs"]) if paired = TRUE, and to quote(italic("n")["obs"]) if paired = FALSE.


Logical that decides whether the experimental design is repeated measures/within-subjects or between-subjects. The default is FALSE.


The type of index used for Credible Interval. Can be "hdi" (default), "eti", or "si" (see si(), hdi(), eti() functions from bayestestR package).


Number of digits after decimal point (should be an integer) (Default: k = 2L).

k.df, k.df.error

Number of decimal places to display for the parameters (default: 0).


Currently ignored.


set.seed(123) # creating a dataframe with stats results stats_df <- statistic = 5.494, df = 29.234, p.value = 0.00001, estimate = -1.980, conf.level = 0.95, conf.low = -2.873, conf.high = -1.088 ) # expression for *t*-statistic with Cohen's *d* as effect size # note that the plotmath expressions need to be quoted statsExpressions::expr_template( no.parameters = 1L, data = stats_df, statistic.text = quote(italic("t")), effsize.text = quote(italic("d")), n = 32L, k = 3L, k.df = 3L )
#> paste(italic("t"), "(", "29.234", ") = ", "5.494", ", ", italic("p"), #> " = ", "1e-05", ", ", italic("d"), " = ", "-1.980", ", CI"["95%"], #> " [", "-2.873", ", ", "-1.088", "]", ", ", italic("n")["obs"], #> " = ", "32")