rules <- apriori(GroceryDS, parameter = list(supp = 0.001, conf = 0.5, maxlen=3))
## Apriori
## 
## Parameter specification:
##  confidence minval smax arem  aval originalSupport maxtime support minlen
##         0.5    0.1    1 none FALSE            TRUE       5   0.001      1
##  maxlen target  ext
##       3  rules TRUE
## 
## Algorithmic control:
##  filter tree heap memopt load sort verbose
##     0.1 TRUE TRUE  FALSE TRUE    2    TRUE
## 
## Absolute minimum support count: 9 
## 
## set item appearances ...[0 item(s)] done [0.00s].
## set transactions ...[169 item(s), 9835 transaction(s)] done [0.00s].
## sorting and recoding items ... [157 item(s)] done [0.00s].
## creating transaction tree ... done [0.00s].
## checking subsets of size 1 2 3
## Warning in apriori(GroceryDS, parameter = list(supp = 0.001, conf = 0.5, :
## Mining stopped (maxlen reached). Only patterns up to a length of 3 returned!
##  done [0.00s].
## writing ... [1472 rule(s)] done [0.00s].
## creating S4 object  ... done [0.00s].
rules <- sort(rules, by="lift", decreasing=TRUE)
inspect(rules[1:10])
##      lhs                         rhs                         support confidence    coverage      lift count
## [1]  {Instant food products,                                                                               
##       soda}                   => {hamburger meat}        0.001220132  0.6315789 0.001931876 18.995654    12
## [2]  {popcorn,                                                                                             
##       soda}                   => {salty snack}           0.001220132  0.6315789 0.001931876 16.697793    12
## [3]  {baking powder,                                                                                       
##       flour}                  => {sugar}                 0.001016777  0.5555556 0.001830198 16.408075    10
## [4]  {ham,                                                                                                 
##       processed cheese}       => {white bread}           0.001931876  0.6333333 0.003050330 15.045491    19
## [5]  {Instant food products,                                                                               
##       whole milk}             => {hamburger meat}        0.001525165  0.5000000 0.003050330 15.038226    15
## [6]  {domestic eggs,                                                                                       
##       processed cheese}       => {white bread}           0.001118454  0.5238095 0.002135231 12.443639    11
## [7]  {liquor,                                                                                              
##       red/blush wine}         => {bottled beer}          0.001931876  0.9047619 0.002135231 11.235269    19
## [8]  {frozen vegetables,                                                                                   
##       specialty chocolate}    => {fruit/vegetable juice} 0.001016777  0.6250000 0.001626843  8.645394    10
## [9]  {instant coffee,                                                                                      
##       other vegetables}       => {whipped/sour cream}    0.001016777  0.5263158 0.001931876  7.342292    10
## [10] {butter,                                                                                              
##       hard cheese}            => {whipped/sour cream}    0.002033554  0.5128205 0.003965430  7.154028    20
plot(rules, method="graph", engine = "igraph", layout = igraph::in_circle(), limit = 10)

forcluster<- GroceryDS[,itemFrequency(GroceryDS) > 0.06]
d_jaccard <- dissimilarity(forcluster, which = "items", method="affinity")
plot(hclust(d_jaccard, method = "ward.D2"), main = "Dendrogram of Grocery items")