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

fuimus:::forager_data() |>
  count_prop(payer, sort = TRUE)
#> # A tibble: 5 × 3
#>   payer       n  prop
#>   <chr>   <int> <dbl>
#> 1 BCBS        3   0.3
#> 2 Cigna       3   0.3
#> 3 Humana      2   0.2
#> 4 Anthem      1   0.1
#> 5 Centene     1   0.1