The goal of tidyttest is to make a t-test function that:
apply()
and purrr::map()
families)You can install tidyttest from GitHub with:
# install.packages("devtools")
devtools::install_github("jrosen48/tidyttest")
This is a basic example which shows you how to use the t_test()
function:
library(dplyr)
library(tidyttest)
storms %>%
filter(status %in% c("tropical depression", "tropical storm")) %>%
mutate(category = as.integer(category)) %>%
t_test(category, status)
#> [1] "mean in group tropical depression is 1"
#> [1] "mean in group tropical storm is 2"
#> [1] "Test statistic is -4375"
#> [1] "P-value is 0"
#> [1] "Effect size is -109.07"
It outputs a tibble
:
t_test_df <- storms %>%
filter(status %in% c("tropical depression", "tropical storm")) %>%
mutate(category = as.integer(category)) %>%
t_test(category, status)
#> [1] "mean in group tropical depression is 1"
#> [1] "mean in group tropical storm is 2"
#> [1] "Test statistic is -4375"
#> [1] "P-value is 0"
#> [1] "Effect size is -109.07"
t_test_df
#> # A tibble: 1 x 5
#> group_1_mean group_2_mean test_statistic p_value effect_size
#> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 2 -4375 0 -109.07
You can also use it without a pipeline:
storms_ss <- storms %>%
filter(status %in% c("tropical depression", "tropical storm")) %>%
mutate(category = as.integer(category))
t_test_df <- t_test(storms_ss, category, status)
#> [1] "mean in group tropical depression is 1"
#> [1] "mean in group tropical storm is 2"
#> [1] "Test statistic is -4375"
#> [1] "P-value is 0"
#> [1] "Effect size is -109.07"
t_test_df
#> # A tibble: 1 x 5
#> group_1_mean group_2_mean test_statistic p_value effect_size
#> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 2 -4375 0 -109.07
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.