rfm_table_customer: RFM table (customer data)

Description Usage Arguments Value Examples

View source: R/rfm-table-customer.R

Description

Recency, frequency, monetary and RFM score.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
rfm_table_customer(
  data = NULL,
  customer_id = NULL,
  n_transactions = NULL,
  recency_days = 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.

recency_days

Number of days since the last transaction.

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.

Value

rfm_table_order returns a list with the following:

rfm

RFM table.

analysis_date

Date of analysis.

frequency_bins

Number of bins used for frequency score.

recency_bins

Number of bins used for recency score.

monetary_bins

Number of bins used for monetary score.

threshold

tibble with thresholds used for generating RFM scores.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
analysis_date <- lubridate::as_date('2007-01-01')
rfm_table_customer(rfm_data_customer, customer_id, number_of_orders,
recency_days, revenue, analysis_date)

# access rfm table
result <- rfm_table_customer(rfm_data_customer, customer_id, number_of_orders,
recency_days, revenue, analysis_date)
result$rfm

# using custom threshold 
rfm_table_customer(rfm_data_customer, customer_id, number_of_orders, 
recency_days, revenue, analysis_date, recency_bins = c(115, 181, 297, 482), 
frequency_bins = c(4, 5, 6, 8), monetary_bins = c(256, 382, 506, 666))

rfm documentation built on July 21, 2020, 5:06 p.m.