Description Usage Arguments See Also Examples
View source: R/license-history.R
Intended to run before make_history
to ensure that
multi-year/lifetime sales are accounted for.
The default (and intended purpose) is to pick the maximum "duration" value
per customer-year. Optionally, it will also pick the minimum value of month
(intended for mid-year dashboards) if first_month = TRUE.
1 2 |
sale |
data frame: Input sales data |
rank_var |
character: name of variable(s) to use for ranking |
grp_var |
character: name of variable(s) used for grouping |
first_month |
logical: If TRUE, also ensures the output contains the earliest month by grp_var (intended for mid-year dashboards) |
Salic Function Reference: salic
Other license history functions: history_check
,
make_history
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | library(dplyr)
data(lic, sale)
sale_unranked <- inner_join(lic, sale)
sale_ranked <- rank_sale(sale_unranked)
# check sale ranking - highest duration will always be picked
left_join(
count(sale_ranked, duration),
distinct(sale_unranked, cust_id, year, duration) %>% count(duration),
by = "duration",
suffix = c(".ranked", ".unranked")
)
# with earliest month included
sale_ranked <- rank_sale(sale_unranked, first_month = TRUE)
left_join(
count(sale_ranked, month),
distinct(sale_unranked, cust_id, year, month) %>% count(month),
by = "month",
suffix = c(".ranked", ".unranked")
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.