Skip to contents

Count and calculate proportion of each group

Usage

count_prop(df, var, sort = FALSE, na.rm = FALSE)

Arguments

df

A <data.frame> or <tibble>

var

A <character> or <symbol> specifying the column 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

mock_forager() |>
  count_prop(payer, sort = TRUE)
#> # A tibble: 8 × 3
#>   payer        n  prop
#>   <fct>    <int> <dbl>
#> 1 BCBS         2   0.2
#> 2 MAO          2   0.2
#> 3 Anthem       1   0.1
#> 4 Centene      1   0.1
#> 5 Cigna        1   0.1
#> 6 Humana       1   0.1
#> 7 Medicare     1   0.1
#> 8 UHC          1   0.1