Skip to content

Instantly share code, notes, and snippets.

@havlikp
Last active February 9, 2016 07:18
Show Gist options
  • Save havlikp/091cf9be8f772f636b56 to your computer and use it in GitHub Desktop.
Save havlikp/091cf9be8f772f636b56 to your computer and use it in GitHub Desktop.
## R setup (https://github.com/hoxo-m/easyRFM)
install.packages("devtools") # if you have not installed "devtools" package
devtools::install_github("hoxo-m/easyRFM")
library(easyRFM)
## setwd("~/Desktop")
## Load / View Data
data <- rfm_generate_data(30000, begin="2014-01-01", end="2015-12-31", seed=123)
summary(data$payment)
## Calculate RFM
RFM <- rfm_auto(data, breaks=list(r=7, f=7, m=7))
## Review Results
RFM$breaks
RFM$classes
RFM$get_table("RF")
## Export Result
write.csv(RFM$rfm, file = "rfm.csv", row.names = FALSE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment