t_test_mverse
performs t-tests across the multiverse.
If x or y is specified, then performs one and two sample t-tests
on specified columns of the data. If both x and y are NULL, then
performs t.test based on the formula branches.
t_test_mverse(
.mverse,
x = NULL,
y = NULL,
alternative = "two.sided",
mu = 0,
paired = FALSE,
var.equal = FALSE,
conf.level = 0.95
)
a mverse
object.
(optional) column name of data within mverse object
(optional) column name of data within mverse object
a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less". You can specify just the initial letter.
a number indicating the true value of the mean (or difference in means if you are performing a two sample test).
a logical indicating whether you want a paired t-test.
a logical variable indicating whether to treat the two variances as being equal.
confidence level of the interval.
a multiverse table displaying the t-test results as a tibble.
# Performing a unpaired two sample t-test.
library(dplyr)
#>
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#>
#> filter, lag
#> The following objects are masked from ‘package:base’:
#>
#> intersect, setdiff, setequal, union
mv <- soccer %>%
filter(!is.na(rater1), !is.na(rater2)) %>%
mverse()
x <- mutate_branch(
((rater1 + rater2) / 2) > mean((rater1 + rater2) / 2),
ifelse(rater1 > rater2, rater1 > 0.5, rater2 > 0.5)
)
y <- mutate_branch(
redCards, yellowCards, yellowReds
)
two_sample_form <- formula_branch(y ~ x)
mv <- mv %>%
add_mutate_branch(x, y) %>%
add_formula_branch(two_sample_form)
t_test_mverse(mv)
#> # A tibble: 6 × 13
#> universe x_branch y_branch two_sample_form_branch statistic p.value
#> <fct> <fct> <fct> <fct> <dbl> <dbl>
#> 1 1 x_1 y_1 two_sample_form_1 -1.90 5.68e- 2
#> 2 2 x_1 y_2 two_sample_form_1 5.65 1.58e- 8
#> 3 3 x_1 y_3 two_sample_form_1 -0.446 6.55e- 1
#> 4 4 x_2 y_1 two_sample_form_1 -0.876 3.81e- 1
#> 5 5 x_2 y_2 two_sample_form_1 7.95 1.98e-15
#> 6 6 x_2 y_3 two_sample_form_1 0.218 8.28e- 1
#> # ℹ 7 more variables: conf.lower <dbl>, conf.upper <dbl>,
#> # `mean in group FALSE` <dbl>, `mean in group TRUE` <dbl>,
#> # x_branch_code <fct>, y_branch_code <fct>, two_sample_form_branch_code <fct>