title: Sorting Association Rules in R
body: <p>I'm trying to accomplish the goals stated below and have oodles of errors. I've spent a lot of time trying to sort the rules and just print the top ten. I know how to print out the entire list.</p>
  
  <p>Use R, to explore generating rules in larger data files. Consider the Adult data
  (available in R with the > <code>data(Adult)</code> command).
  Generate the association rules with a confidence threshold of 0.8</p>
  
  <ol>
  <li>Print out the top 10 rules sorted by support. Consider using the
  inspect command along with sort and indexing into the sorted rules.</li>
  <li>Print out the top 10 rules sorted by confidence.</li>
  <li>Look at generating rules that are restricted to have income on the
  lhs of the rule. Note, options for income are two values: small and
  large. Consider including the appearance parameter of the <code>apriori</code>
  function. Print the first 10 rules sorted by lift.</li>
  </ol>
  
  <p>Here is my code so far:</p>
  
  <pre><code>library(arules)    
  library(arulesViz)
  
  data(Adult)
  head(Adult)
  
  rules &lt;- apriori(Adult, parameter = list(supp = 0.5, conf = 0.8))
  
  top.support &lt;- sort(rules, decreasing = TRUE, na.last = NA, by = "support")
  top.ten.support &lt;- sort.list(top.support, partial=10)
  inspect(top.ten.support)
  
  top.confidence &lt;- sort(rules, decreasing = TRUE, na.last = NA, by = "confidence")
  top.ten.confidence &lt;- sort.list(top.support,partial=10)
  inspect(top.ten.confidence)
  
  rules2 &lt;- apriori(Adult, parameter=list(supp = 0.5, conf = 0.8), appearance = income)
  
  top.lift &lt;- sort(rules2, decreasing = TRUE, na.last = NA, by = "lift")
  top.ten.lift &lt;- sort.list(top.lift, partial=10)
  inspect(top.ten.lift)
  </code></pre>