title: how to convert data.frame to transactions for arules
body: <p>I read data from a csv file, the data has 3 columns, one is transaction id, the other two are product and product catagory. I need to convert this into transactions in order to use the <code>apriori</code> function in <strong>arules</strong>. It shows an error when I convert to transactions:</p>
  
  <pre><code>dat &lt;- read.csv("spss.csv",head=TRUE,sep="," , as.is = T)
  dat[,2] &lt;- factor(dat[,2])
  dat[,3] &lt;- factor(dat[,3])
  spssdat &lt;- dat[,c(1,2,3)]
  str(spssdat)
  
  'data.frame':   108919 obs. of  3 variables:
   $ Transaction_id: int  3000312 3000312 3001972 3003361 3003361 3003361 3003361 3003361 3003361 3004637 ...
   $ product_catalog : Factor w/ 9 levels "AIM","BA","IM",..: 1 1 5 7 7 7 7 7 7 1 ...
   $ product      : Factor w/ 332 levels "ACM","ACTG/AIM",..: 7 7 159 61 61 61 61 61 61 7 ...
  
  trans4 &lt;- as(spssdat, "transactions")
  
  Error in as(spssdat, "transactions") : 
    no method or default for coercing “data.frame” to “transactions”
  </code></pre>
  
  <p>If the data only have two columns, it can work by:</p>
  
  <pre><code>trans4 &lt;- as(split(spssdat[,2], spssdat[,1]), "transactions")
  </code></pre>
  
  <p>But I don't know how to convert when I have 3 columns. Usually there are the additional columns likes category attributes, customer attributes. so the column usually large than 2 columns. need to find rules between multiple columns.</p>