Recency, frequency, monetary and RFM score.
rfm_table_order( data = NULL, customer_id = NULL, order_date = NULL, revenue = NULL, analysis_date = NULL, recency_bins = 5, frequency_bins = 5, monetary_bins = 5, ... )
data | A |
---|---|
customer_id | Unique id of the customer. |
order_date | Date of the transaction. |
revenue | Revenue from the customer. |
analysis_date | Date of analysis. |
recency_bins | Number of bins for recency or custom threshold. |
frequency_bins | Number of bins for frequency or custom threshold. |
monetary_bins | Number of bins for monetary or custom threshold. |
... | Other arguments. |
rfm_table_order
returns a list with the following:
RFM table.
Date of analysis.
Number of bins used for frequency score.
Number of bins used for recency score.
Number of bins used for monetary score.
tibble with thresholds used for generating RFM scores.
analysis_date <- lubridate::as_date('2006-12-31') rfm_table_order(rfm_data_orders, customer_id, order_date, revenue, analysis_date)#> # A tibble: 995 x 9 #> customer_id date_most_recent recency_days transaction_cou~ amount #> <chr> <date> <dbl> <dbl> <dbl> #> 1 Abbey O'Re~ 2006-06-09 205 6 472 #> 2 Add Senger 2006-08-13 140 3 340 #> 3 Aden Lesch~ 2006-06-20 194 4 405 #> 4 Admiral Se~ 2006-08-21 132 5 448 #> 5 Agness O'K~ 2006-10-02 90 9 843 #> 6 Aileen Bar~ 2006-10-08 84 9 763 #> 7 Ailene Her~ 2006-03-25 281 8 699 #> 8 Aiyanna Br~ 2006-04-29 246 4 157 #> 9 Ala Schmid~ 2006-01-16 349 3 363 #> 10 Alannah Bo~ 2005-04-21 619 4 196 #> # ... with 985 more rows, and 4 more variables: recency_score <int>, #> # frequency_score <int>, monetary_score <int>, rfm_score <dbl># access rfm table result <- rfm_table_order(rfm_data_orders, customer_id, order_date, revenue, analysis_date) result$rfm#> # A tibble: 995 x 9 #> customer_id date_most_recent recency_days transaction_cou~ amount #> <chr> <date> <dbl> <dbl> <dbl> #> 1 Abbey O'Re~ 2006-06-09 205 6 472 #> 2 Add Senger 2006-08-13 140 3 340 #> 3 Aden Lesch~ 2006-06-20 194 4 405 #> 4 Admiral Se~ 2006-08-21 132 5 448 #> 5 Agness O'K~ 2006-10-02 90 9 843 #> 6 Aileen Bar~ 2006-10-08 84 9 763 #> 7 Ailene Her~ 2006-03-25 281 8 699 #> 8 Aiyanna Br~ 2006-04-29 246 4 157 #> 9 Ala Schmid~ 2006-01-16 349 3 363 #> 10 Alannah Bo~ 2005-04-21 619 4 196 #> # ... with 985 more rows, and 4 more variables: recency_score <int>, #> # frequency_score <int>, monetary_score <int>, rfm_score <dbl># using custom threshold rfm_table_order(rfm_data_orders, customer_id, order_date, revenue, analysis_date, recency_bins = c(115, 181, 297, 482), frequency_bins = c(4, 5, 6, 8), monetary_bins = c(256, 382, 506, 666))#> # A tibble: 995 x 9 #> customer_id date_most_recent recency_days transaction_cou~ amount #> <chr> <date> <dbl> <dbl> <dbl> #> 1 Abbey O'Re~ 2006-06-09 205 6 472 #> 2 Add Senger 2006-08-13 140 3 340 #> 3 Aden Lesch~ 2006-06-20 194 4 405 #> 4 Admiral Se~ 2006-08-21 132 5 448 #> 5 Agness O'K~ 2006-10-02 90 9 843 #> 6 Aileen Bar~ 2006-10-08 84 9 763 #> 7 Ailene Her~ 2006-03-25 281 8 699 #> 8 Aiyanna Br~ 2006-04-29 246 4 157 #> 9 Ala Schmid~ 2006-01-16 349 3 363 #> 10 Alannah Bo~ 2005-04-21 619 4 196 #> # ... with 985 more rows, and 4 more variables: recency_score <int>, #> # frequency_score <int>, monetary_score <int>, rfm_score <dbl>