Learn R Programming

rfm (version 0.2.0)

rfm_table_customer_2: RFM table 2 (customer data)

Description

Recency, frequency, monetary and RFM score.

Usage

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

Run this code
# NOT RUN {
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)

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

# }

Run the code above in your browser using DataLab