How to do it...

Perform the following steps to analyze the association rules:

  1. First, you need to load the Groceries dataset:
        > data(Groceries)  
  1. You can then examine the summary of the Groceries dataset:
        > summary(Groceries)  
  1. Next, you can use itemFrequencyPlot to examine the relative item frequency of itemsets:
        > itemFrequencyPlot(Groceries, support = 0.1, cex.names=0.8,        topN=5) 
The top five item frequency bar plot of groceries transactions
  1. Use apriori to discover rules with support over 0.001 and confidence over 0.5:
        > rules = apriori(Groceries, parameter = list(supp = 0.001, conf = 0.5, target= "rules")) > summary(rules) Output ...

Get Machine Learning with R Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.