Displaying transactions and associations

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

Getting ready

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

How to do it…

Perform the following steps to display transactions and associations:

  1. First, obtain a LIST representation of the transaction data:
    > head(LIST(trans),3)
    $'00001'
    [1] "P0014520085"
    
    $'00002'
    [1] "P0018800250"
    
    $'00003'
    [1] "P0003926850034" "P0013344760004" "P0013834251" ...

Get R for Data Science Cookbook 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.