Market Basket Analysis in R

basketMarket Basket Analysis (MBA) or Affinity Analysis or Association Analysis is an analysis to understand combination and sequence of activities. Originally linked to understanding products bought together in a basket by a customer.

Detailed description on Market Basket Analysis

Install Required Packages

For Market Basket or Association Analysis, arules and arulesViz have to be installed and loaded

Read Data for Market Basket Analysis

Belgium Grocery store data is  used as sample data for market basket analysis in this blog.

Exploratory Data Analysis

One of the first step is to check the basic information about the data. This will help us in addressing any issues with the data creation or reading. And also help in building our understanding of the data

Counting number of items in each of these orders.


Convert data into “transaction” class before using Association Analysis functions.



Association or Market basket Analysis Rules

Association Rules build by apriori algorithm can be selected using support, lift or confidence.





Product Combinations


1 thought on “Market Basket Analysis in R

Leave a Comment