enter image description hereAnyone can help with the suggestion how to covert the following data formate to the one 'Arules' can use. the dataset named 'df' is like
'Recieptnumber' , 'ProductName' 1 , egg 1 , apple 2 , water 3 , chips 3 , apple 3 , paper .....
was using table(df) function to create matrix ---thoughts that is spares matrix . but it can not be used in 'Arules' package
any suggestion how to transfer the dataset? Thank you!
Either use read.transactions()
if you have it in a file or use the example from ? transactions
:
a_df3 <- data.frame(
TID = c(1,1,2,2,2,3),
item=c("a","b","a","b","c", "b")
)
a_df3
trans4 <- as(split(a_df3[,"item"], a_df3[,"TID"]), "transactions")
trans4
inspect(trans4)