Displaying transactions and associations

The arule package uses its own transactions class to store transaction data. As such, we must use the generic function provided by arule to display transactions and association rules. In this recipe, we will illustrate how to display transactions and association rules via various functions in the arule package.

Getting ready

Ensure that you have completed the previous recipe by generating transactions and storing these in the variable, trans.

How to do it...

Perform the following steps to display transactions and associations:

  1. First, you can obtain a LIST representation of the transaction data:
    > LIST(trans)
    $Tr1
    [1] "Apple" "Bread" "Cake" 
    
    $Tr2
    [1] "Apple" "Bread" "Milk" 
    
    $Tr3
    [1] "Bread" "Cake"  "Milk"
    
  2. Next, ...

Get R: Recipes for Analysis, Visualization and Machine Learning now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.