Learn R Programming

rfm (version 0.2.0)

rfm_table_customer: RFM table (customer data)

Description

Recency, frequency, monetary and RFM score.

Usage

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.

frequency_bins

Number of bins for frequency.

monetary_bins

Number of bins for monetary.

...

Other arguments.

Value

rfm_table_customer 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

Run this code
# NOT RUN {
analysis_date <- lubridate::as_date('2007-01-01', tz = 'UTC')
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

# }

Run the code above in your browser using DataLab