rfm

Customer Segmentation using RFM Analysis

https://github.com/rsquaredacademy/rfm

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.3%) to scientific vocabulary

Keywords

customer-analytics customer-segmentation rfm-analysis rstats segmentation
Last synced: 6 months ago · JSON representation

Repository

Customer Segmentation using RFM Analysis

Basic Info
Statistics
  • Stars: 63
  • Watchers: 6
  • Forks: 27
  • Open Issues: 7
  • Releases: 6
Topics
customer-analytics customer-segmentation rfm-analysis rstats segmentation
Created over 8 years ago · Last pushed over 1 year ago
Metadata Files
Readme Changelog Contributing License Support

README.Rmd

---
output: github_document
---



```{r, echo = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "tools/README-"
)
options(tibble.print_min = 5, tibble.print_max = 5)
```

# rfm 


[![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/rfm)](https://cran.r-project.org/package=rfm) [![R build status](https://github.com/rsquaredacademy/rfm/workflows/R-CMD-check/badge.svg)](https://github.com/rsquaredacademy/rfm/actions) [![Coverage Status](https://img.shields.io/codecov/c/github/rsquaredacademy/rfm/master.svg)](https://app.codecov.io/github/rsquaredacademy/rfm?branch=master) 


## Overview

Tools for customer segmentation using RFM (recency, frequency and monetary) analysis.  

## Installation

```{r gh-installation, eval = FALSE}
# Install rfm from CRAN
install.packages("rfm")

# Or the development version from GitHub
# install.packages("pak")
pak::pak("rsquaredacademy/rfm")
```

```{r, echo=FALSE, message=FALSE}
library(rfm)
```

## Usage

**RFM** (recency, frequency, monetary) analysis is a behavior based technique used to segment customers by examining their transaction history such as:

- how recently a customer has purchased (recency)
- how often they purchase (frequency)
- how much the customer spends (monetary)

It is based on the marketing axiom that **80% of your business comes from 20% of your customers**. RFM analysis helps to identify customers who are more likely to respond to promotions by segmenting them into various categories.

To calculate the RFM score we need the following info for each customer: 

- a unique customer id 
- date of transaction/order
- transaction/order amount

```{r rfm_table_order}
# analysis date
analysis_date <- as.Date('2006-12-31')

# generate rfm score
rfm_result <- rfm_table_order(rfm_data_orders, customer_id, order_date,
revenue, analysis_date)

# rfm score
rfm_result

# segment names
segment_names <- c("Champions", "Potential Loyalist", "Loyal Customers",
                   "Promising", "New Customers", "Can't Lose Them",
                   "At Risk", "Need Attention", "About To Sleep", "Lost")

# segment intervals
recency_lower <-   c(5, 3, 2, 3, 4, 1, 1, 1, 2, 1)
recency_upper <-   c(5, 5, 4, 4, 5, 2, 2, 3, 3, 1)
frequency_lower <- c(5, 3, 2, 1, 1, 3, 2, 3, 1, 1)
frequency_upper <- c(5, 5, 4, 3, 3, 4, 5, 5, 3, 5)
monetary_lower <-  c(5, 2, 2, 3, 1, 4, 4, 3, 1, 1)
monetary_upper <-  c(5, 5, 4, 5, 5, 5, 5, 5, 4, 5)

# generate segments
segments <- rfm_segment(rfm_result, segment_names, recency_lower,
recency_upper, frequency_lower, frequency_upper, monetary_lower,
monetary_upper)

segments
```

### Plotting Engines

`rfm` supports the following plotting engines:

- [ggplot2](https://ggplot2.tidyverse.org)
- [plotly](https://plotly.com/r/)
- [gganimate](https://gganimate.com) 

### Shiny App

`rfm` includes a shiny app for interactive RFM analysis. In the latest release, we have added project management features to allow users to save/clone their projects. 

## Resources

- [Online Course](https://rsquared-academy.thinkific.com/courses/customer-segmentation-using-rfm-analysis)
- [YouTube Tutorial](https://www.youtube.com/watch?v=275X7yaSsoQ)
- [Blog](https://blog.rsquaredacademy.com/customer-segmentation-using-rfm-analysis/)

## Getting Help

If you encounter a bug, please file a minimal reproducible example using 
[reprex](https://reprex.tidyverse.org/index.html) on github. For questions and
clarifications, use [StackOverflow](https://stackoverflow.com/).

Owner

  • Name: Rsquared Academy
  • Login: rsquaredacademy
  • Kind: organization
  • Email: pkgs@rsquaredacademy.com
  • Location: Bengaluru, India

GitHub Events

Total
  • Issues event: 2
  • Watch event: 2
  • Issue comment event: 2
  • Fork event: 1
Last Year
  • Issues event: 2
  • Watch event: 2
  • Issue comment event: 2
  • Fork event: 1

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 370
  • Total Committers: 3
  • Avg Commits per committer: 123.333
  • Development Distribution Score (DDS): 0.011
Past Year
  • Commits: 8
  • Committers: 1
  • Avg Commits per committer: 8.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
rsquaredin r****n@g****m 366
Martin Gubri m****i@f****g 2
leungi i****g@o****m 2
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 49
  • Total pull requests: 47
  • Average time to close issues: 6 months
  • Average time to close pull requests: about 10 hours
  • Total issue authors: 11
  • Total pull request authors: 4
  • Average comments per issue: 1.0
  • Average comments per pull request: 0.09
  • Merged pull requests: 46
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 4
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 2
  • Pull request authors: 0
  • Average comments per issue: 0.5
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • aravindhebbali (37)
  • gfagherazzi (2)
  • leungi (2)
  • abdullahtanveerdata (1)
  • mramos-stellar (1)
  • DavidGarciaEstaun (1)
  • sckott (1)
  • Yvanyvanyvan (1)
  • paleolimbot (1)
  • IeUDE (1)
  • verajosemanuel (1)
Pull Request Authors
  • aravindhebbali (45)
  • leungi (1)
  • elalbaicin (1)
  • Framartin (1)
Top Labels
Issue Labels
feature (11) enhancement (8) docs (8) bug (7) refactor (2) ci (1)
Pull Request Labels
docs (6) refactor (3) enhancement (3) bug (2) feature (1)

Packages

  • Total packages: 1
  • Total downloads:
    • cran 3,073 last-month
  • Total dependent packages: 1
  • Total dependent repositories: 1
  • Total versions: 5
  • Total maintainers: 1
cran.r-project.org: rfm

Recency, Frequency and Monetary Value Analysis

  • Versions: 5
  • Dependent Packages: 1
  • Dependent Repositories: 1
  • Downloads: 3,073 Last month
Rankings
Forks count: 2.8%
Downloads: 6.1%
Stargazers count: 6.4%
Average: 11.4%
Dependent packages count: 18.1%
Dependent repos count: 23.8%
Maintainers (1)
Last synced: 6 months ago

Dependencies

DESCRIPTION cran
  • R >= 3.2 depends
  • RColorBrewer * imports
  • data.table * imports
  • ggplot2 * imports
  • gridExtra * imports
  • magrittr * imports
  • scales * imports
  • stats * imports
  • utils * imports
  • xplorerr * imports
  • DT * suggests
  • covr * suggests
  • kableExtra * suggests
  • knitr * suggests
  • rmarkdown * suggests
  • testthat * suggests
  • vdiffr * suggests