Add test statistics to a grouped desc_table, with the tests specified as variable = test
.
Arguments
- desctable
A desc_table
- .auto
A function to automatically determine the appropriate tests
- .default
A default fallback test
- ...
A list of statistical tests associated to variable names
Tests
The statistical test functions to use in the table are passed as additional named arguments. Tests must be preceded
by a formula tilde (~
).
name = ~test
will apply test test
to variable name
.
Any R test function can be used, as long as it returns an object containing a p.value
element, which is the
case for most tests returning an object of class htest
.
Users can also use purrr::map
-like formulas as quick anonymous functions (eg. ~ t.test(., var.equal = T)
to
compute a t test without the Welch correction.
Examples
iris %>%
group_by(Species) %>%
desc_table() %>%
desc_tests(Sepal.Length = ~kruskal.test,
Sepal.Width = ~oneway.test,
Petal.Length = ~oneway.test(., var.equal = T),
Petal.Length = ~oneway.test(., var.equal = F))
#> # A tibble: 3 × 5
#> # Groups: Species [3]
#> Species data .stats .vars .tests
#> <fct> <list> <list> <list> <list>
#> 1 setosa <tibble [50 × 4]> <df [4 × 8]> <df [4 × 1]> <df [4 × 2]>
#> 2 versicolor <tibble [50 × 4]> <df [4 × 8]> <df [4 × 1]> <df [4 × 2]>
#> 3 virginica <tibble [50 × 4]> <df [4 × 8]> <df [4 × 1]> <df [4 × 2]>