countCustomers: Count customers by group

Description Usage Arguments Value See Also Examples

Description

Count number of customers by group. This function will collect data from the database if using SQL backend.

Usage

1
countCustomers(df, groupVars = NULL)

Arguments

df

A data frame with a column named customerUID

groupVars

A character vector of variable names to group by

Value

A data frame with columns for grouping variables and a column named customers for number of customers Data frame is passed through prettyData function.

See Also

Other analysis functions: calcChurn, calcGenderProportion, calcParticipation, calcRecruitment, countItems, itemGroupCount, sumRevenue

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Demo data: Count number of customers each year purchasing a fishing
# license between 2010 and 2017
filterData(
  dataSource = "csv",
  activeFilters = list(itemType = "Fish", itemYear = c(2010, 2017))
) %>%
  countCustomers(c("itemYear", "itemType"))
## Not run: 
# 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 each year purchasing a fishing
# license between 2010 and 2017
filterData(
  dataSource = "sql",
  conn = myConn,
  activeFilters = list(itemType = "Fish", itemYear = c(2010, 2017))
) %>%
  countCustomers(c("itemYear", "itemType"))

## End(Not run)

chrischizinski/huntfishapp documentation built on Sept. 7, 2020, 12:14 p.m.