Recency, frequency, monetary and RFM score.
rfm_table_customer_2( data = NULL, customer_id = NULL, n_transactions = NULL, latest_visit_date = NULL, total_revenue = NULL, analysis_date = NULL, recency_bins = 5, frequency_bins = 5, monetary_bins = 5, ... )
data | A |
---|---|
customer_id | Unique id of the customer. |
n_transactions | Number of transactions/orders. |
latest_visit_date | Date of the latest visit. |
total_revenue | Total 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('2007-01-01') rfm_table_customer_2(rfm_data_customer, customer_id, number_of_orders, most_recent_visit, revenue, analysis_date)#> # A tibble: 39,999 x 8 #> customer_id recency_days transaction_cou~ amount recency_score #> <dbl> <dbl> <dbl> <dbl> <int> #> 1 22086 232 9 777 2 #> 2 2290 115 16 1555 4 #> 3 26377 43 5 336 5 #> 4 24650 64 12 1189 5 #> 5 12883 23 12 1229 5 #> 6 2119 72 11 929 5 #> 7 31283 112 17 1569 4 #> 8 33815 142 11 778 3 #> 9 15972 43 9 641 5 #> 10 27650 131 10 970 3 #> # ... with 39,989 more rows, and 3 more variables: frequency_score <int>, #> # monetary_score <int>, rfm_score <dbl># access rfm table result <- rfm_table_customer_2(rfm_data_customer, customer_id, number_of_orders, most_recent_visit, revenue, analysis_date) result$rfm#> # A tibble: 39,999 x 8 #> customer_id recency_days transaction_cou~ amount recency_score #> <dbl> <dbl> <dbl> <dbl> <int> #> 1 22086 232 9 777 2 #> 2 2290 115 16 1555 4 #> 3 26377 43 5 336 5 #> 4 24650 64 12 1189 5 #> 5 12883 23 12 1229 5 #> 6 2119 72 11 929 5 #> 7 31283 112 17 1569 4 #> 8 33815 142 11 778 3 #> 9 15972 43 9 641 5 #> 10 27650 131 10 970 3 #> # ... with 39,989 more rows, and 3 more variables: frequency_score <int>, #> # monetary_score <int>, rfm_score <dbl># using custom threshold rfm_table_customer_2(rfm_data_customer, customer_id, number_of_orders, most_recent_visit, 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: 39,999 x 8 #> customer_id recency_days transaction_cou~ amount recency_score #> <dbl> <dbl> <dbl> <dbl> <int> #> 1 22086 232 9 777 3 #> 2 2290 115 16 1555 4 #> 3 26377 43 5 336 5 #> 4 24650 64 12 1189 5 #> 5 12883 23 12 1229 5 #> 6 2119 72 11 929 5 #> 7 31283 112 17 1569 5 #> 8 33815 142 11 778 4 #> 9 15972 43 9 641 5 #> 10 27650 131 10 970 4 #> # ... with 39,989 more rows, and 3 more variables: frequency_score <int>, #> # monetary_score <int>, rfm_score <dbl>