ttest_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.

ttest_mverse(
  .mverse,
  x = NULL,
  y = NULL,
  alternative = "two.sided",
  mu = 0,
  paired = FALSE,
  var.equal = FALSE,
  conf.level = 0.95
)

Arguments

.mverse

a mverse object.

x

(optional) column name of data within mverse object

y

(optional) column name of data within mverse object

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less". You can specify just the initial letter.

mu

a number indicating the true value of the mean (or difference in means if you are performing a two sample test).

paired

a logical indicating whether you want a paired t-test.

var.equal

a logical variable indicating whether to treat the two variances as being equal.

conf.level

confidence level of the interval.

Value

A ttest_mverse object.

Examples

# Performing a unpaired two sample t-test.
mv <- mverse(soccer)
x <- mutate_branch(
  ((rater1 + rater2) / 2) > mean((rater1 + rater2) / 2),
  ifelse(rater1 > rater2, rater1, rater2) >
    mean(ifelse(rater1 > rater2, rater1, rater2))
)
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)
ttest_mverse(mv)
#> Warning: error in default universe
#> Error in t.test.formula(stats::formula(.formula_mverse), data = .data_mverse,  : 
#>   grouping factor must have exactly 2 levels
#> pkgdown::build_site_github_pages -> build_site -> build_site_local -> build_reference -> purrr::map -> map_ -> with_indexed_errors -> withCallingHandlers -> call_with_cleanup -> .f -> withCallingHandlers -> data_reference_topic -> run_examples -> highlight_examples -> downlit::evaluate_and_highlight -> evaluate::evaluate -> evaluate_call -> timing_fn -> handle -> try - f, silent = TRUE) -> withCallingHandlers -> withVisible -> eval_with_user_handlers -> eval -> eval -> ttest_mverse -> multiverse::inside -> execute_universe -> mapply ->  -> execute_code_from_universe -> tryStack -> lapply -> FUN -> FUN -> stats::t.test -> t.test.formula -> stop -> t.test.formula(stats::formula(.formula_mverse), data = .data_mverse, 
#> Warning: error in default universe
#> Error in t.test.formula(stats::formula(.formula_mverse), data = .data_mverse,  : 
#>   grouping factor must have exactly 2 levels
#> pkgdown::build_site_github_pages -> build_site -> build_site_local -> build_reference -> purrr::map -> map_ -> with_indexed_errors -> withCallingHandlers -> call_with_cleanup -> .f -> withCallingHandlers -> data_reference_topic -> run_examples -> highlight_examples -> downlit::evaluate_and_highlight -> evaluate::evaluate -> evaluate_call -> timing_fn -> handle -> try - f, silent = TRUE) -> withCallingHandlers -> withVisible -> eval_with_user_handlers -> eval -> eval -> ttest_mverse -> multiverse::inside -> execute_universe -> mapply ->  -> execute_code_from_universe -> tryStack -> lapply -> FUN -> FUN -> stats::t.test -> t.test.formula -> stop -> t.test.formula(stats::formula(.formula_mverse), data = .data_mverse, 
#> Warning: error in default universe
#> Error in FUN(X[[i]], ...) : object 'htest' not found
#> pkgdown::build_site_github_pages -> build_site -> build_site_local -> build_reference -> purrr::map -> map_ -> with_indexed_errors -> withCallingHandlers -> call_with_cleanup -> .f -> withCallingHandlers -> data_reference_topic -> run_examples -> highlight_examples -> downlit::evaluate_and_highlight -> evaluate::evaluate -> evaluate_call -> timing_fn -> handle -> try - f, silent = TRUE) -> withCallingHandlers -> withVisible -> eval_with_user_handlers -> eval -> eval -> ttest_mverse -> multiverse::inside -> execute_universe -> mapply ->  -> execute_code_from_universe -> tryStack -> lapply -> FUN -> FUN -> as.data.frame -> dplyr::rename -> as.data.frame -> t -> FUN(X[[i]], ...)
#> Warning: error in universe 1
#> Error in t.test.formula(stats::formula(.formula_mverse), data = .data_mverse,  : 
#>   grouping factor must have exactly 2 levels
#>  pkgdown::build_site_github_pages -> build_site -> build_site_local -> build_reference -> purrr::map -> map_ -> with_indexed_errors -> withCallingHandlers -> call_with_cleanup -> .f -> withCallingHandlers -> data_reference_topic -> run_examples -> highlight_examples -> downlit::evaluate_and_highlight -> evaluate::evaluate -> evaluate_call -> timing_fn -> handle -> try - f, silent = TRUE) -> withCallingHandlers -> withVisible -> eval_with_user_handlers -> eval -> eval -> ttest_mverse -> execute_multiverse -> execute_multiverse.mverse -> multiverse::execute_multiverse -> mapply ->  -> app -> FUN -> tryStack -> lapply -> FUN -> FUN -> stats::t.test -> t.test.formula -> stop -> t.test.formula(stats::formula(.formula_mverse), data = .data_mverse,  
#> 
#> Warning: error in universe 2
#> Error in t.test.formula(stats::formula(.formula_mverse), data = .data_mverse,  : 
#>   grouping factor must have exactly 2 levels
#>  pkgdown::build_site_github_pages -> build_site -> build_site_local -> build_reference -> purrr::map -> map_ -> with_indexed_errors -> withCallingHandlers -> call_with_cleanup -> .f -> withCallingHandlers -> data_reference_topic -> run_examples -> highlight_examples -> downlit::evaluate_and_highlight -> evaluate::evaluate -> evaluate_call -> timing_fn -> handle -> try - f, silent = TRUE) -> withCallingHandlers -> withVisible -> eval_with_user_handlers -> eval -> eval -> ttest_mverse -> execute_multiverse -> execute_multiverse.mverse -> multiverse::execute_multiverse -> mapply ->  -> app -> FUN -> tryStack -> lapply -> FUN -> FUN -> stats::t.test -> t.test.formula -> stop -> t.test.formula(stats::formula(.formula_mverse), data = .data_mverse,  
#> 
#> Warning: error in universe 3
#> Error in t.test.formula(stats::formula(.formula_mverse), data = .data_mverse,  : 
#>   grouping factor must have exactly 2 levels
#>  pkgdown::build_site_github_pages -> build_site -> build_site_local -> build_reference -> purrr::map -> map_ -> with_indexed_errors -> withCallingHandlers -> call_with_cleanup -> .f -> withCallingHandlers -> data_reference_topic -> run_examples -> highlight_examples -> downlit::evaluate_and_highlight -> evaluate::evaluate -> evaluate_call -> timing_fn -> handle -> try - f, silent = TRUE) -> withCallingHandlers -> withVisible -> eval_with_user_handlers -> eval -> eval -> ttest_mverse -> execute_multiverse -> execute_multiverse.mverse -> multiverse::execute_multiverse -> mapply ->  -> app -> FUN -> tryStack -> lapply -> FUN -> FUN -> stats::t.test -> t.test.formula -> stop -> t.test.formula(stats::formula(.formula_mverse), data = .data_mverse,  
#> 
#> Warning: error in universe 4
#> Error in t.test.formula(stats::formula(.formula_mverse), data = .data_mverse,  : 
#>   grouping factor must have exactly 2 levels
#>  pkgdown::build_site_github_pages -> build_site -> build_site_local -> build_reference -> purrr::map -> map_ -> with_indexed_errors -> withCallingHandlers -> call_with_cleanup -> .f -> withCallingHandlers -> data_reference_topic -> run_examples -> highlight_examples -> downlit::evaluate_and_highlight -> evaluate::evaluate -> evaluate_call -> timing_fn -> handle -> try - f, silent = TRUE) -> withCallingHandlers -> withVisible -> eval_with_user_handlers -> eval -> eval -> ttest_mverse -> execute_multiverse -> execute_multiverse.mverse -> multiverse::execute_multiverse -> mapply ->  -> app -> FUN -> tryStack -> lapply -> FUN -> FUN -> stats::t.test -> t.test.formula -> stop -> t.test.formula(stats::formula(.formula_mverse), data = .data_mverse,  
#> 
#> Warning: error in universe 5
#> Error in t.test.formula(stats::formula(.formula_mverse), data = .data_mverse,  : 
#>   grouping factor must have exactly 2 levels
#>  pkgdown::build_site_github_pages -> build_site -> build_site_local -> build_reference -> purrr::map -> map_ -> with_indexed_errors -> withCallingHandlers -> call_with_cleanup -> .f -> withCallingHandlers -> data_reference_topic -> run_examples -> highlight_examples -> downlit::evaluate_and_highlight -> evaluate::evaluate -> evaluate_call -> timing_fn -> handle -> try - f, silent = TRUE) -> withCallingHandlers -> withVisible -> eval_with_user_handlers -> eval -> eval -> ttest_mverse -> execute_multiverse -> execute_multiverse.mverse -> multiverse::execute_multiverse -> mapply ->  -> app -> FUN -> tryStack -> lapply -> FUN -> FUN -> stats::t.test -> t.test.formula -> stop -> t.test.formula(stats::formula(.formula_mverse), data = .data_mverse,  
#> 
#> Warning: error in universe 6
#> Error in t.test.formula(stats::formula(.formula_mverse), data = .data_mverse,  : 
#>   grouping factor must have exactly 2 levels
#>  pkgdown::build_site_github_pages -> build_site -> build_site_local -> build_reference -> purrr::map -> map_ -> with_indexed_errors -> withCallingHandlers -> call_with_cleanup -> .f -> withCallingHandlers -> data_reference_topic -> run_examples -> highlight_examples -> downlit::evaluate_and_highlight -> evaluate::evaluate -> evaluate_call -> timing_fn -> handle -> try - f, silent = TRUE) -> withCallingHandlers -> withVisible -> eval_with_user_handlers -> eval -> eval -> ttest_mverse -> execute_multiverse -> execute_multiverse.mverse -> multiverse::execute_multiverse -> mapply ->  -> app -> FUN -> tryStack -> lapply -> FUN -> FUN -> stats::t.test -> t.test.formula -> stop -> t.test.formula(stats::formula(.formula_mverse), data = .data_mverse,  
#> 
#> Warning: error in universe 1
#> Error in FUN(X[[i]], ...) : object 'htest' not found
#>  pkgdown::build_site_github_pages -> build_site -> build_site_local -> build_reference -> purrr::map -> map_ -> with_indexed_errors -> withCallingHandlers -> call_with_cleanup -> .f -> withCallingHandlers -> data_reference_topic -> run_examples -> highlight_examples -> downlit::evaluate_and_highlight -> evaluate::evaluate -> evaluate_call -> timing_fn -> handle -> try - f, silent = TRUE) -> withCallingHandlers -> withVisible -> eval_with_user_handlers -> eval -> eval -> ttest_mverse -> execute_multiverse -> execute_multiverse.mverse -> multiverse::execute_multiverse -> mapply ->  -> app -> FUN -> tryStack -> lapply -> FUN -> FUN -> as.data.frame -> dplyr::rename -> as.data.frame -> t -> FUN(X[[i]], ...) 
#> 
#> Warning: error in universe 2
#> Error in FUN(X[[i]], ...) : object 'htest' not found
#>  pkgdown::build_site_github_pages -> build_site -> build_site_local -> build_reference -> purrr::map -> map_ -> with_indexed_errors -> withCallingHandlers -> call_with_cleanup -> .f -> withCallingHandlers -> data_reference_topic -> run_examples -> highlight_examples -> downlit::evaluate_and_highlight -> evaluate::evaluate -> evaluate_call -> timing_fn -> handle -> try - f, silent = TRUE) -> withCallingHandlers -> withVisible -> eval_with_user_handlers -> eval -> eval -> ttest_mverse -> execute_multiverse -> execute_multiverse.mverse -> multiverse::execute_multiverse -> mapply ->  -> app -> FUN -> tryStack -> lapply -> FUN -> FUN -> as.data.frame -> dplyr::rename -> as.data.frame -> t -> FUN(X[[i]], ...) 
#> 
#> Warning: error in universe 3
#> Error in FUN(X[[i]], ...) : object 'htest' not found
#>  pkgdown::build_site_github_pages -> build_site -> build_site_local -> build_reference -> purrr::map -> map_ -> with_indexed_errors -> withCallingHandlers -> call_with_cleanup -> .f -> withCallingHandlers -> data_reference_topic -> run_examples -> highlight_examples -> downlit::evaluate_and_highlight -> evaluate::evaluate -> evaluate_call -> timing_fn -> handle -> try - f, silent = TRUE) -> withCallingHandlers -> withVisible -> eval_with_user_handlers -> eval -> eval -> ttest_mverse -> execute_multiverse -> execute_multiverse.mverse -> multiverse::execute_multiverse -> mapply ->  -> app -> FUN -> tryStack -> lapply -> FUN -> FUN -> as.data.frame -> dplyr::rename -> as.data.frame -> t -> FUN(X[[i]], ...) 
#> 
#> Warning: error in universe 4
#> Error in FUN(X[[i]], ...) : object 'htest' not found
#>  pkgdown::build_site_github_pages -> build_site -> build_site_local -> build_reference -> purrr::map -> map_ -> with_indexed_errors -> withCallingHandlers -> call_with_cleanup -> .f -> withCallingHandlers -> data_reference_topic -> run_examples -> highlight_examples -> downlit::evaluate_and_highlight -> evaluate::evaluate -> evaluate_call -> timing_fn -> handle -> try - f, silent = TRUE) -> withCallingHandlers -> withVisible -> eval_with_user_handlers -> eval -> eval -> ttest_mverse -> execute_multiverse -> execute_multiverse.mverse -> multiverse::execute_multiverse -> mapply ->  -> app -> FUN -> tryStack -> lapply -> FUN -> FUN -> as.data.frame -> dplyr::rename -> as.data.frame -> t -> FUN(X[[i]], ...) 
#> 
#> Warning: error in universe 5
#> Error in FUN(X[[i]], ...) : object 'htest' not found
#>  pkgdown::build_site_github_pages -> build_site -> build_site_local -> build_reference -> purrr::map -> map_ -> with_indexed_errors -> withCallingHandlers -> call_with_cleanup -> .f -> withCallingHandlers -> data_reference_topic -> run_examples -> highlight_examples -> downlit::evaluate_and_highlight -> evaluate::evaluate -> evaluate_call -> timing_fn -> handle -> try - f, silent = TRUE) -> withCallingHandlers -> withVisible -> eval_with_user_handlers -> eval -> eval -> ttest_mverse -> execute_multiverse -> execute_multiverse.mverse -> multiverse::execute_multiverse -> mapply ->  -> app -> FUN -> tryStack -> lapply -> FUN -> FUN -> as.data.frame -> dplyr::rename -> as.data.frame -> t -> FUN(X[[i]], ...) 
#> 
#> Warning: error in universe 6
#> Error in FUN(X[[i]], ...) : object 'htest' not found
#>  pkgdown::build_site_github_pages -> build_site -> build_site_local -> build_reference -> purrr::map -> map_ -> with_indexed_errors -> withCallingHandlers -> call_with_cleanup -> .f -> withCallingHandlers -> data_reference_topic -> run_examples -> highlight_examples -> downlit::evaluate_and_highlight -> evaluate::evaluate -> evaluate_call -> timing_fn -> handle -> try - f, silent = TRUE) -> withCallingHandlers -> withVisible -> eval_with_user_handlers -> eval -> eval -> ttest_mverse -> execute_multiverse -> execute_multiverse.mverse -> multiverse::execute_multiverse -> mapply ->  -> app -> FUN -> tryStack -> lapply -> FUN -> FUN -> as.data.frame -> dplyr::rename -> as.data.frame -> t -> FUN(X[[i]], ...) 
#> 
#> # A tibble: 6 × 8
#>   universe x_branch y_branch two_sample_form_branch out   x_branch_code         
#>   <fct>    <fct>    <fct>    <fct>                  <lgl> <fct>                 
#> 1 1        x_1      y_1      two_sample_form_1      NA    "((rater1 + rater2)/2…
#> 2 2        x_1      y_2      two_sample_form_1      NA    "((rater1 + rater2)/2…
#> 3 3        x_1      y_3      two_sample_form_1      NA    "((rater1 + rater2)/2…
#> 4 4        x_2      y_1      two_sample_form_1      NA    "ifelse(rater1 > rate…
#> 5 5        x_2      y_2      two_sample_form_1      NA    "ifelse(rater1 > rate…
#> 6 6        x_2      y_3      two_sample_form_1      NA    "ifelse(rater1 > rate…
#> # ℹ 2 more variables: y_branch_code <fct>, two_sample_form_branch_code <fct>