comparison.Rd
Compares the means/proportions across grouping by group
. Produces a p- value for each comparsion.
comparison(df, group, ...)
df | a dataframe |
---|---|
group | the grouping variable; must be a |
... | columns to compare means/proportions |
a data frame
This function produces either a t.test
or a chisq.test
on each of the columns in ...
. If the variable is.numeric
, conducts t.test
. If the variable is.logical
or is.factor
, conducts chisq.test
. Note that if you are piping into this function with a variable created by dplyr::group_by()
as as your grouping function, you must first dplyr::ungroup()
prior to piping into compare()
(see example).
#> # A tibble: 2 × 5 #> rowname `hp > 150_false` `hp > 150_true` p.value method #> <chr> <dbl> <dbl> <dbl> <chr> #> 1 hp 99.5 216. 0.000000340 Welch Two Sample t-test #> 2 am 0.526 0.231 0.0916 Welch Two Sample t-test