grouped_ttest: Function to run _t_-test on multiple variables across...

Description Usage Arguments Value Examples

View source: R/grouped_ttest.R

Description

Function to run t-test on multiple variables across multiple grouping variables.

Usage

1
2
3
4
5
6
7
8
grouped_ttest(
  data,
  dep.vars,
  indep.vars,
  grouping.vars,
  paired = FALSE,
  var.equal = FALSE
)

Arguments

data

Dataframe from which variables are to be taken.

dep.vars

List dependent variables for a t-test (y in y ~ x).

indep.vars

List independent variables for a t-test (x in y ~ x).

grouping.vars

List of grouping variables.

paired

A logical indicating whether you want a paired t-test (Default: paired = FALSE; independent t-test, i.e.).

var.equal

A logical variable indicating whether to treat the two variances as being equal. If TRUE, then the pooled variance is used to estimate the variance otherwise the Welch (or Satterthwaite) approximation to the degrees of freedom is used (Default: var.equal = FALSE; Welch's t-test, i.e.).

Value

A tibble dataframe with tidy results from t-test analyses.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# for reproducibility
set.seed(123)

groupedstats::grouped_ttest(
  data = dplyr::filter(.data = ggplot2::diamonds, color == "E" | color == "J"),
  dep.vars = c(carat, price, depth),
  indep.vars = color,
  grouping.vars = clarity,
  paired = FALSE,
  var.equal = FALSE
)

groupedstats documentation built on May 29, 2021, 1:06 a.m.