Function to run proportion test on grouped data.

grouped_proptest(data, grouping.vars, measure, ...)

Arguments

data

Dataframe (or tibble) from which variables are to be taken.

grouping.vars

Grouping variables.

measure

A variable for which proportion test needs to be carried out for each combination of levels of factors entered in grouping.vars.

...

Currently ignored.

Value

Dataframe with percentages and statistical details from a proportion test.

Examples

# for reproducibility set.seed(123) groupedstats::grouped_proptest( data = mtcars, grouping.vars = cyl, measure = am )
#> Warning: Chi-squared approximation may be incorrect
#> # A tibble: 3 x 8 #> cyl `0` `1` statistic p.value parameter #> <dbl> <chr> <chr> <dbl> <dbl> <dbl> #> 1 4 27.27% 72.73% 2.27 0.132 1 #> 2 6 57.14% 42.86% 0.143 0.705 1 #> 3 8 85.71% 14.29% 7.14 0.00753 1 #> method significance #> <chr> <chr> #> 1 Chi-squared test for given probabilities ns #> 2 Chi-squared test for given probabilities ns #> 3 Chi-squared test for given probabilities **