Selects the correct statistical test for a provided dataframe column.

choose_test(df, group, col)

Arguments

df

a data frame

group

a grouping variable to split the records in col and test by.

col

a column to be tested

Value

a list of class htest representing the results of either chisq.test or t.test

Details

currently does not work with factors, only logicals and numerics.

Examples

mtcars %>% dplyr::group_by(hp > 150) %>% choose_test(`hp > 150`, mpg)
#> #> Welch Two Sample t-test #> #> data: mpg by hp > 150 #> t = 5.239, df = 28.746, p-value = 1.338e-05 #> alternative hypothesis: true difference in means between group FALSE and group TRUE is not equal to 0 #> 95 percent confidence interval: #> 4.799001 10.949177 #> sample estimates: #> mean in group FALSE mean in group TRUE #> 23.28947 15.41538 #>