I have been trying to do sequential analysis of products purchased after a certain period of time, like what products combination are being purchased after 7 days by customers and what proportion of customers are purchasing such combination, i have tried arulesSequence package but my data is structured in a way which doesn't go with the package, i have userid, date of purchase, product id and product name in columns, i have searched a lot but haven't got any clear way to do.
Dayy UID leaf_category_name leaf_category_id
5/1/2018 47 Cubes 38860
5/1/2018 272 Pastas & Noodles 34616
5/1/2018 1827 Flavours & Spices 34619
5/1/2018 3505 Feature Phones 1506
this is the kind of data i have, UID stands for user id, leaf category is product purchased in simple terms. I have huge dataset with 2,049,278 rows.
codes i have tried-
library(Matrix)
library(arules)
library(arulesSequences)
library(arulesViz)
#splitting data into transactions
transactions <- as(split(data$leaf_category_id, data$UID), "transactions")
frequent_sequences <- cspade(transactions, parameter=list(support=0.5))
and
# Convert tabular data to sequences. Item is in
# column 1, sequence ID is column 2, and event ID is column 3.
seqs = make_sequences(data, item_col = 1, sid_col = 2, eid_col = 3)
# generate frequent sequential patterns with minimum
# support of 0.1 and maximum of 6 elements
fseq = spade(seqs, 0.1, 6)
I want to look at sequence of products being purchased after certain days. Can someone help me with this?
Thank You