I would like to count the number of subsequences in list. Say I have data given by:
data = {1, 1, 1, 2, 1, 2, 2, 2, 1, 2, 1};
I would like to count the number times I see the following subsequences: {1,1}, {1,2}, {2,1}, {2,2}
. Is there a quick way to do so? I've tried a few approaches using Count
and Cases
with no luck. Any advice would be greatly appreciated.
Thanks!