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, ...)

Arguments

data

A data.frame or tibble.

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.

frequency_bins

Number of bins for frequency.

monetary_bins

Number of bins for monetary.

...

Other arguments.

Value

rfm_table_customer_2 returns a tibble with the following columns:

customer_id

Unique id of the customer.

recency_days

Number of days since the most recent transaction.

transaction_count

Total number of transactions of the customer.

amount

Revenue from the customer.

recency_score

Recency score of the customer.

frequency_score

Frequency score of the customer.

monetary_score

Monetary score of the customer.

rfm_score

RFM score of the customer.

Examples

analysis_date <- lubridate::as_date('2007-01-01', tz = 'UTC') 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_count 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_count 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>