Method two Creating a physical transactions file
Now that you know how to run association rules using the coerce to dataframe
method, we will now illustrate the write to file
method:
In the
write to file
method, each item is written to a separate line, along with the identifying key, which in our case is theInvoiceId
The advantage to the
write to file
method is that very large data files can be accumulated separately, and then combined together if neededYou can use the
file.show
function to display the contents of the file that will be input to the association rules algorithm:
setwd("C:/PracticalPredictiveAnalytics/Data") load("OnlineRetail.full.Rda") OnlineRetail <- OnlineRetail[1:100,] nrow(OnlineRetail) > [1] 268034 head(OnlineRetail) > InvoiceNo StockCode Description Quantity > 5 6365 71053 METAL LANTERN 6 > 6 536365 21730 GLASS STAR FROSTED T-LIGHT HOLDER 6 > 2 536365 22752 SET 7 BABUSHKA NESTING BOXES 2...