Data understanding and preparation

For this analysis, we will only need to load two packages as well as the Groceries dataset:

> library(arules)

> library(arulesViz)

> data(Groceries)
> head(Groceries)
> str(Groceries)
> Groceries
transactions in sparse format with
 9835 transactions (rows) and
 169 items (columns)

This dataset is structured as a sparse matrix object known as the class of transaction.

So, once the structure is that of the class transaction, our standard exploration techniques will not work, but the arules package offers us other techniques to explore the data. On a side note, if you have a data frame or matrix and want to convert it to the transaction class, you can do this with a simple syntax using the as() function. The following ...

Get R: Unleash Machine Learning Techniques 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.