Skip to contents

Create a dataset that combines past (from the elog) and future (from the forecast model) summaries by year and month.

Usage

forecast_scenario_past_plus_future(elog, scenario, pred)

Arguments

elog

Event log, a data.frame with field cust for the customer ID and field date for the date/time of the event, which should be of type Date or POSIXt. If sales or returns field is present, it will be aggregated. See details for more information.

scenario

Numeric. Scenario to produce the summary for.

pred

Forecast model generated by fit_forecast_model(), must have year and month column attached

Examples


scenario_predictions$forecasts$year <- 2016:2020
scenario_predictions$forecasts$month <- c(rep("January", 5))

# Past plus future data                      
 forecast_scenario_past_plus_future(
    elog_validated$elog,
    scenario = 1,
    pred = scenario_predictions
 )                     
#> # A tibble: 55 × 7
#>     year month    unique_custs    tx   sales month_num date      
#>    <dbl> <chr>           <int> <dbl>   <dbl>     <dbl> <date>    
#>  1  2016 January            NA 1819. 216417          1 2016-01-01
#>  2  2017 April              73   80   10141.         4 2017-04-01
#>  3  2017 August            130  138   16952.         8 2017-08-01
#>  4  2017 December          265  292   39718.        12 2017-12-01
#>  5  2017 February           71   76   11494.         2 2017-02-01
#>  6  2017 January            NA 2984. 363164          1 2017-01-01
#>  7  2017 July              181  212   21475.         7 2017-07-01
#>  8  2017 June               96  105   13343.         6 2017-06-01
#>  9  2017 March              76   80   11175.         3 2017-03-01
#> 10  2017 May               135  154   19325.         5 2017-05-01
#> # ℹ 45 more rows