Function to run t-test on multiple variables across multiple grouping variables.
grouped_ttest(
data,
dep.vars,
indep.vars,
grouping.vars,
paired = FALSE,
var.equal = FALSE
)
Dataframe from which variables are to be taken.
List dependent variables for a t-test (y
in y ~ x
).
List independent variables for a t-test (x
in y ~ x
).
List of grouping variables.
A logical indicating whether you want a paired t-test (Default:
paired = FALSE
; independent t-test, i.e.).
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.).
A tibble dataframe with tidy results from t-test analyses.
# NOT RUN {
# 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
)
# }
Run the code above in your browser using DataLab