grouped_proptest: Function to run proportion test on grouped data.

Description Usage Arguments Value Examples

View source: R/grouped_proptest.R

Description

Function to run proportion test on grouped data.

Usage

1
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

1
2
3
4
5
6
7
8
# for reproducibility
set.seed(123)

groupedstats::grouped_proptest(
  data = mtcars,
  grouping.vars = cyl,
  measure = am
)

Example output

sh: 1: cannot create /dev/null: Permission denied
sh: 1: cannot create /dev/null: Permission denied
Registered S3 method overwritten by 'broom.mixed':
  method      from 
  tidy.gamlss broom
# A tibble: 3 x 8
    cyl `0`    `1`   statistic p.value parameter method             significance
  <dbl> <chr>  <chr>     <dbl>   <dbl>     <dbl> <chr>              <chr>       
1     4 27.27% 72.7…     2.27  0.132           1 Chi-squared test … ns          
2     6 57.14% 42.80.143 0.705           1 Chi-squared testns          
3     8 85.71% 14.27.14  0.00753         1 Chi-squared test**          
Warning message:
In stats::chisq.test(xtab) : Chi-squared approximation may be incorrect

groupedstats documentation built on May 29, 2021, 1:06 a.m.