RFM is frequently employed in customer analytics and tools like SPSS have built in functions to perform it. This repository is an effort to make a similar package for R.
Sample data set : "sales" Fictional dataset containing customer names, date of purchase and amount of purchase.
library(RFM) head(sales)
Perform simple RFM analysis on the data
rfm(sales)
By default, Recency is calculated from the current date. This behaviour can be altered by specifying Analysis date.
#RFM with analysis date as 20th of Jan 2016 rfm(sales,analysisDate = "2016/01/20")
Note the dates have to be in "yyyy/mm/dd" format. eg : 2016/12/23.
By default, the function looks for "customer", "date" and "amount" columns.
Custom column names may be specified:
#Creating sales data set with customer, billDate and revenue as column names newsales = sales names(newsales) = c("customer", "billDate", "revenue") rfm(newsales,analysisDate = "2016/01/20", customer = "customer", date = "billDate", revenue = "revenue")
Installation
#Uncomment block below #install.packages("devtools") #library(devtools) #install_github("astrosyam/RFM")
Disclaimer: This is an initial commit and is therefore limited to basic RFM. The code is currently not optimized or bug free.
Wishlist
Future commits will add the following functionalities:
Custom weightage of components, for eg. MFR, where Monetary has a higher preference than Recency while scoring.
Specify custom bins for scoring
Customer purchase latency
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.