We'll start by mining the data for the overall association rules before moving on to our rules for beer specifically. Throughout the modeling process, we'll use the apriori algorithm, which is the appropriately named apriori() function in the arules package. The two main things that we'll need to specify in the function are the dataset and parameters. As for the parameters, you'll need to apply judgment when determining the minimum support, confidence, and the minimum and/or maximum length of basket items in an itemset. Using item frequency plots, along with trial and error, let's set the minimum support at 1 in 1,000 transactions and the minimum confidence at 90 %.
Additionally, let's establish the maximum number of items to be associated as 4. The following code creates the object that we'll call rules:
rules <-
...