A tidier version of t.test() for two sample tests.
t_test(data, formula, order = NULL, alternative = "two_sided", mu = 0, conf_int = TRUE, conf_level = 0.95, ...)
A data frame that can be coerced into a tibble.
A formula with the response variable on the left and the explanatory on the right.
A string vector of specifying the order in which the levels of
the explanatory variable should be ordered for subtraction, where
Character string giving the direction of the alternative
hypothesis. Options are
A numeric value giving the hypothesized null mean value for a one sample test and the hypothesized difference for a two sample test.
A logical value for whether to include the confidence
interval or not.
A numeric value between 0 and 1. Default value is 0.95.
For passing in other arguments to t.test().
# t test for comparing mpg against automatic/manual mtcars %>% dplyr::mutate(am = factor(am)) %>% t_test(mpg ~ am, order = c("1", "0"), alternative = "less")#> # A tibble: 1 x 6 #> statistic t_df p_value alternative lower_ci upper_ci #> <dbl> <dbl> <dbl> <chr> <dbl> <dbl> #> 1 3.77 18.3 0.999 less -Inf 10.6