title: Xtabs command error
body: <p>I have recently started learning to use R. I imported a csv data into R and used xtabs with it.</p>
  
  <p>I use the following commands:</p>
  
  <pre><code>train.df=read.csv("train.csv")
  xtabs( ~class, data=train.df)
  </code></pre>
  
  <p>I get the error: </p>
  
  <pre><code>Error in model.frame.default(formula = ~class, data = train.df) : 
    object is not a matrix
  </code></pre>
  
  <p>I tried xtabs command with the dataset given at the bottom of <a href="http://www.r-bloggers.com/classification-trees/" rel="nofollow">this</a> page and it works fine. I even tried converting my dataset into a matrix using 
  as.matrix(train.df)
  but this doesnt work either. </p>
  
  <p>Can someone please point out what the problem is?</p>
  
  <p>Thanks</p>