Count customers who bought each combination of permits and stamps

itemGroupCount(df)

Arguments

df

A data frame

See also

Examples

# Demo data: Count number of customers by combination of items purchased filterData( dataSource = "csv", activeFilters = list( itemType = c("Fish", "Deer", "Spring Turkey"), itemYear = c(2018, 2018) ) ) %>% itemGroupCount()
#> # A tibble: 21 x 5 #> groupID customers itemType purchase degree #> <int> <int> <chr> <dbl> <dbl> #> 1 1 1466 Deer 0 1 #> 2 1 1466 Fish 1 1 #> 3 1 1466 Spring Turkey 0 1 #> 4 2 770 Deer 1 1 #> 5 2 770 Fish 0 1 #> 6 2 770 Spring Turkey 0 1 #> 7 3 164 Deer 1 2 #> 8 3 164 Fish 1 2 #> 9 3 164 Spring Turkey 0 2 #> 10 4 130 Deer 0 1 #> # … with 11 more rows
if (FALSE) { # Database connection. Suggest using keyring package to avoid hardcoding # passwords myConn <- DBI::dbConnect(odbc::odbc(), dsn = "HuntFishApp", # Your datasource name uid = keyring::key_get("HuntFishAppUID"), # Your username pwd = keyring::key_get("HuntFishAppPWD") ) # Your password # SQL Backend: Count number of customers by combination of items purchased filterData( dataSource = "sql", conn = myConn, activeFilters = list( itemType = c("Fish", "Deer", "Spring Turkey"), itemYear = c(2018, 2018) ) ) %>% itemGroupCount() }