I have a 1 column, 2000 row dataframe. Each row contains a customer event sequence that concludes with a purchase of item X. The dataframe looks as follows:

call.agent -> schedule.appointment -> withdraw cash -> buy X 
enter branch -> call.agent -> enter branch -> enter branch -> buy X

There are up to 500 events in 1 sequence, and events like entering a branch or calling an agent can repeat in the sequence.

What type of analysis / package in R can I use to determine what patterns, event sequences or groups of events are most likely to lead to the purchase of X? The matrix is very sparse, so this is much more of an unsupervised learning problem.

I want to understand what combinations / sequences or itemsets appear most frequently -- leading to open account. What algorithm or R package can I use? Is this association rules? It is a little different since they all lead to open account and I don't want to know what drives any of the items prior to it.

I was thinking arules but they frequently do not allow for repeating items in a basket. I am also looking into the TramineR package...


  • $\begingroup$ I have a similar problem, unfortunately your question is very old. I'm using the arulesSequences package, which could also fit your data. What did you do about it? I have an additional difficulty: I have X1, X2, ... that can be bought, and some of them appear very rarely. So the support is really low and it never generates rules for it... And I don't know if I can combine than as one X (I don't need to distinguish, just need to know one of them was bought) but if the patterns that lead to each X are too different it might also not work... Any ideas? $\endgroup$ – Verena Haunschmid Oct 28 '15 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.