Skip to contents

Count rows and columns and pivot to wide format

Usage

count_wide(df, rows, cols)

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

Examples

mock_forager(10) |>
  count_wide(c(class), payer)
#> # A tibble: 2 × 7
#>   class     Anthem  BCBS Centene Medicaid Medicare   UHC
#>   <ord>      <int> <int>   <int>    <int>    <int> <int>
#> 1 Primary        1     1       0        0        0     1
#> 2 Secondary      0     1       1        1        1     3