Collection of plots or data tables to export, using the customer
level data output from fit_customer_model().
Usage
customer_level_output(
cust_data,
config,
type = c("cohort_summary", "p_alive", "p_churn", "e_aov", "p_return", "captured_tx",
"expected_tx", "total_tx", "clv", "moic"),
main_color = appraise_pal()(4)[4],
output = c("plot", "data"),
group,
textsmooth = TRUE,
...
)Arguments
- cust_data
Individual level estimates created by
fit_customer_model().- config
Configuration list created by
appraise_configure().- type
Type of output to produce. Note that
type = moicrequires the cust_data to be theforecastsdataset from thefit_customer_model().- main_color
Main color to use in plots.
- output
Plot or table to return.
- group
Unquoted variable name. Variable to group (color & fill) the charts by.
- textsmooth
Logical. Whether to use
geomtextpath::geom_textsmooth()(TRUE) or the regularggplot2::geom_smooth()(FALSE)- ...
Further arguments to
geomtextpath::geom_textsmooth()orggplot2::geom_smooth().
Examples
config <- appraise_configure(sample = TRUE,
cpa = c(25, 50, 75, 100, 125, 150, 200),
cm = c(.2, .3, .432, .5),
currency = '$',
n_forecast = 5,
aws_bucket = 'monorepo-data/med',
google_drive_id = '1laRarNAPgZlBGkztQgHAYgs7Xy2l0le9')
# Plot example
clv_plot <-
customer_level_output(
cust_data = customer_level_predictions$customer_level_data,
config = config,
type = "clv",
output = "plot"
) + appraise_theme()
# MOIC example
moic_plot <-
customer_level_output(
cust_data = customer_level_predictions$forecasts,
config = config,
type = "moic",
output = "plot"
) + appraise_theme()
# Data example
customer_level_output(
cust_data = customer_level_predictions$customer_level_data,
config = config,
type = "cohort_summary",
output = "data"
)
#> # A tibble: 5 × 7
#> year_acquired n_custs aov p_alive p_return total_clv_cust total_tx_cust
#> <chr> <int> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 2017 648 133. 0.303 0.0148 387. 2.72
#> 2 2018 776 144. 0.320 0.0137 405. 2.67
#> 3 2019 1165 135. 0.358 0.0142 392. 2.87
#> 4 2020 1690 121. 0.409 0.0567 316. 2.82
#> 5 2021 720 116. 0.502 0.0827 308. 2.98