statsExpressions (version 0.3.1)

expr_template: Template for subtitles with statistical details for tests

Description

Template for subtitles with statistical details for tests

Usage

expr_template(
  no.parameters,
  stat.title = NULL,
  statistic.text,
  stats.df,
  effsize.text,
  effsize.df,
  n,
  conf.level = 0.95,
  k = 2L,
  k.parameter = 0L,
  k.parameter2 = 0L,
  n.text = NULL,
  ...
)

Arguments

no.parameters

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.

stat.title

A character describing the test being run, which will be added as a prefix in the subtitle. The default is NULL. An example of a stat.title argument will be something like "Student's t-test: ".

statistic.text

A character that specifies the relevant test statistic. For example, for tests with t-statistic, statistic.text = "t". If you want to use plotmath, you will have to quote the argument (e.g., quote(italic("t"))).

stats.df

A dataframe containing the following columns:

  • statistic: the numeric value of a statistic.

  • parameter: 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.

  • parameter1, parameter2 relevant only if the statistic in question has two degrees of freedom (e.g., anova).

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

effsize.text

A character that specifies the relevant effect size. For example, for Cohen's d statistic, effsize.text = "d". If you want to use plotmath, you will have to quote the argument (e.g., quote(italic("d"))).

effsize.df

A dataframe containing the following columns:

  • estimate: estimated value of the effect size.

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

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

n

An integer specifying the sample size used for the test.

conf.level

Scalar between 0 and 1. If unspecified, the defaults return 95% lower and upper confidence intervals (0.95).

k

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

k.parameter, k.parameter2

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

n.text

A character that specifies the design, which will determine what the n stands for. For example, for repeated measures, this can be quote(italic("n")["pairs"]), while for independent subjects design this can be quote(italic("n")["obs"]). If NULL, defaults to generic quote(italic("n")).

...

Currently ignored.

Examples

Run this code
# NOT RUN {
set.seed(123)

# creating a dataframe with stats results
stats_df <- cbind.data.frame(
  statistic = 5.494,
  parameter = 29.234,
  p.value = 0.00001
)

# creating a dataframe with effect size results
effsize_df <- cbind.data.frame(
  estimate = -1.980,
  conf.low = -2.873,
  conf.high = -1.088
)

# subtitle for *t*-statistic with Cohen's *d* as effect size
statsExpressions::expr_template(
  no.parameters = 1L,
  stats.df = stats_df,
  effsize.df = effsize_df,
  statistic.text = quote(italic("t")),
  effsize.text = quote(italic("d")),
  n = 32L,
  conf.level = 0.95,
  k = 3L,
  k.parameter = 3L
)
# }

Run the code above in your browser using DataCamp Workspace