Imagine 10000 receipts sitting on your table. Each receipt represents a transaction with items that were purchased. The receipt is a representation of stuff that went into a customer’s basket - and therefore ‘Market Basket Analysis’.

That is exactly what the Groceries Data Set contains: a collection of receipts with each line representing 1 receipt and the items purchased. Each line is called a transaction and each column in a row represents an item. The data set is attached.

Your assignment is to use R to mine the data for association rules. You should report support, confidence and lift and your top 10 rules by lift.

Extra credit: do a simple cluster analysis on the data as well. Use whichever packages you like. Due May 3 before midnight.

library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.1.3
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.4.0     v purrr   0.3.4
## v tibble  3.1.8     v dplyr   1.0.8
## v tidyr   1.2.0     v stringr 1.4.0
## v readr   2.1.2     v forcats 0.5.1
## Warning: package 'ggplot2' was built under R version 4.1.3
## Warning: package 'tibble' was built under R version 4.1.3
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(ggplot2)
library(arules)
## Warning: package 'arules' was built under R version 4.1.3
## Loading required package: Matrix
## Warning: package 'Matrix' was built under R version 4.1.3
## 
## Attaching package: 'Matrix'
## The following objects are masked from 'package:tidyr':
## 
##     expand, pack, unpack
## 
## Attaching package: 'arules'
## The following object is masked from 'package:dplyr':
## 
##     recode
## The following objects are masked from 'package:base':
## 
##     abbreviate, write
library(arulesViz)
## Warning: package 'arulesViz' was built under R version 4.1.3

For this analysis, I will be using the ‘arules’ and ‘arulesviz’ libraries.

We will read the data using the read.transactions function. To vizualize the top 20 items purchased, we will be using the ‘itemFrequencyPlot’ function.

recipts <- read.transactions("GroceryDataSet.csv", sep=",")
itemFrequencyPlot(recipts, topN=20, type="absolute", main="The top 10 features", col=rainbow(20))

Association Rules

To find the association rules, we will use the ‘apriori’ function.

rules<- apriori(recipts, parameter=list(supp=0.001, conf=0.5) , control=list(verbose=FALSE))
summary(rules)
## set of 5668 rules
## 
## rule length distribution (lhs + rhs):sizes
##    2    3    4    5    6 
##   11 1461 3211  939   46 
## 
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    2.00    3.00    4.00    3.92    4.00    6.00 
## 
## summary of quality measures:
##     support           confidence        coverage             lift       
##  Min.   :0.001017   Min.   :0.5000   Min.   :0.001017   Min.   : 1.957  
##  1st Qu.:0.001118   1st Qu.:0.5455   1st Qu.:0.001729   1st Qu.: 2.464  
##  Median :0.001322   Median :0.6000   Median :0.002135   Median : 2.899  
##  Mean   :0.001668   Mean   :0.6250   Mean   :0.002788   Mean   : 3.262  
##  3rd Qu.:0.001729   3rd Qu.:0.6842   3rd Qu.:0.002949   3rd Qu.: 3.691  
##  Max.   :0.022267   Max.   :1.0000   Max.   :0.043416   Max.   :18.996  
##      count      
##  Min.   : 10.0  
##  1st Qu.: 11.0  
##  Median : 13.0  
##  Mean   : 16.4  
##  3rd Qu.: 17.0  
##  Max.   :219.0  
## 
## mining info:
##     data ntransactions support confidence
##  recipts          9835   0.001        0.5
##                                                                                                  call
##  apriori(data = recipts, parameter = list(supp = 0.001, conf = 0.5), control = list(verbose = FALSE))

Below are the top 10 association rules arranged by lift.

top_10 <- rules %>% DATAFRAME() %>% arrange(desc(lift)) %>% top_n(10)
## Selecting by count
top_10
##                                      LHS                RHS    support
## 1       {root vegetables,tropical fruit} {other vegetables} 0.01230300
## 2           {rolls/buns,root vegetables} {other vegetables} 0.01220132
## 3               {root vegetables,yogurt} {other vegetables} 0.01291307
## 4               {root vegetables,yogurt}       {whole milk} 0.01453991
## 5       {domestic eggs,other vegetables}       {whole milk} 0.01230300
## 6           {rolls/buns,root vegetables}       {whole milk} 0.01270971
## 7           {other vegetables,pip fruit}       {whole milk} 0.01352313
## 8                {tropical fruit,yogurt}       {whole milk} 0.01514997
## 9              {other vegetables,yogurt}       {whole milk} 0.02226741
## 10 {other vegetables,whipped/sour cream}       {whole milk} 0.01464159
##    confidence   coverage     lift count
## 1   0.5845411 0.02104728 3.020999   121
## 2   0.5020921 0.02430097 2.594890   120
## 3   0.5000000 0.02582613 2.584078   127
## 4   0.5629921 0.02582613 2.203354   143
## 5   0.5525114 0.02226741 2.162336   121
## 6   0.5230126 0.02430097 2.046888   125
## 7   0.5175097 0.02613116 2.025351   133
## 8   0.5173611 0.02928317 2.024770   149
## 9   0.5128806 0.04341637 2.007235   219
## 10  0.5070423 0.02887646 1.984385   144

We can see the visual representation of these tules below.

head(top_10, n = 10, by = "lift") %>% 
    plot(method = "graph", engine = "htmlwidget")
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "method" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "engine" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "method" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "engine" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "method" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "engine" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "method" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "engine" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "method" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "engine" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "method" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "engine" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "method" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "engine" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "method" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "engine" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "method" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "engine" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "method" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "engine" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "method" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "engine" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "method" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "engine" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "method" is not a
## graphical parameter
## Warning in plot.xy(xy.coords(x, y), type = type, ...): "engine" is not a
## graphical parameter
## Warning in plot.window(...): "method" is not a graphical parameter
## Warning in plot.window(...): "engine" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "method" is not a graphical parameter
## Warning in plot.xy(xy, type, ...): "engine" is not a graphical parameter
## Warning in title(...): "method" is not a graphical parameter
## Warning in title(...): "engine" is not a graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "method" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "engine" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "method" is not a
## graphical parameter
## Warning in axis(side = side, at = at, labels = labels, ...): "engine" is not a
## graphical parameter

Cluster Analysis

For cluster analysis, we will use the ‘hclust’ function. We will be focusing on the items that have greater than 5% support.

recipts <- recipts[ , itemFrequency(recipts) > 0.05]
d_jaccard <- dissimilarity(recipts, which = "items")
plot(hclust(d_jaccard, method = "ward.D2"), 
     main = "Features Clustering", sub = "", xlab = "")