title: subsetting arules by lhs in R
body: <p>I want to subset the rules produced by running apiriori algorithm in R in the following manner.</p>
  
  <p>The rule subset must have LHS which has to only have any of the items in another list(say items). No constraints are applied on RHS.</p>
  
  <p>I tried the following code but I couldn't get the results as expected:</p>
  
  <pre><code>&gt; library(arules)
  &gt; library(datasets)
  &gt; data(Groceries)
  &gt; rules &lt;- apriori(Groceries, parameter = list(supp = 0.001, conf = 0.8))
  inspect(head(rules))
      lhs                                 rhs            support     confidence lift     
  [1] {liquor,red/blush wine}          =&gt; {bottled beer} 0.001931876 0.9047619  11.235269
  [2] {curd,cereals}                   =&gt; {whole milk}   0.001016777 0.9090909   3.557863
  [3] {yogurt,cereals}                 =&gt; {whole milk}   0.001728521 0.8095238   3.168192
  [4] {butter,jam}                     =&gt; {whole milk}   0.001016777 0.8333333   3.261374
  [5] {soups,bottled beer}             =&gt; {whole milk}   0.001118454 0.9166667   3.587512
  [6] {napkins,house keeping products} =&gt; {whole milk}   0.001321810 0.8125000   3.179840
  
  items = c("curd","cereals")
  rules.subset2 &lt;- subset(rules, subset = all(lhs %in% items))
  </code></pre>
  
  <p>This sub-setting operation results in the following (which is wrong because I only want to have "curd and cereals" as LHS in the rule-subset)</p>
  
  <pre><code>inspect(head(rules.subset2))
            lhs                                                                           rhs                support     confidence lift     
      [1]   {liquor,red/blush wine}                                                    =&gt; {bottled beer}     0.001931876 0.9047619  11.235269
      [2]   {curd,cereals}                                                             =&gt; {whole milk}       0.001016777 0.9090909   3.557863
      [3]   {yogurt,cereals}                                                           =&gt; {whole milk}       0.001728521 0.8095238   3.168192
      [4]   {butter,jam}                                                               =&gt; {whole milk}       0.001016777 0.8333333   3.261374
      [5]   {soups,bottled beer}                                                       =&gt; {whole milk}       0.001118454 0.9166667   3.587512
      [6]   {napkins,house keeping products}                                           =&gt; {whole milk}       0.001321810 0.8125000   3.179840
  </code></pre>
  
  <p>I tried finding answers on this web site but no luck. I also tried various other methods but I was not successful. </p>
  
  <p>I would appreciate any help from you.</p>