Skip to contents

Count and calculate proportion of each group

Usage

count_prop_multi(df, rows, cols, sort = FALSE, na.rm = FALSE)

Arguments

df

A <data.frame> or <tibble>

rows

A <character> or <symbol> specifying the rows to count

cols

A <character> or <symbol> specifying the columns to count

sort

A <logical> indicating whether to sort the output by frequency, default is FALSE

na.rm

A <logical> indicating whether to remove missing values from the count, default is FALSE

Examples

fuimus:::forager_data(10) |>
  count_prop_multi(
  c(ins_class),
  payer,
  sort = TRUE)
#> # A tibble: 8 × 4
#>   ins_class payer            n  prop
#>   <chr>     <chr>        <int> <dbl>
#> 1 Primary   Anthem           2   0.2
#> 2 Primary   UnitedHealth     2   0.2
#> 3 Primary   BCBS             1   0.1
#> 4 Primary   Medicaid         1   0.1
#> 5 Secondary Centene          1   0.1
#> 6 Secondary Cigna            1   0.1
#> 7 Secondary Medicaid         1   0.1
#> 8 Secondary Medicare         1   0.1