title: classification in R
body: <p>I am trying to do naive bayes classification in R. I have seen this example in following link.</p>
  
  <p><a href="http://en.wikibooks.org/wiki/Data_Mining_Algorithms_In_R/Classification/Na%C3%AFve_Bayes" rel="nofollow">http://en.wikibooks.org/wiki/Data_Mining_Algorithms_In_R/Classification/Na%C3%AFve_Bayes</a></p>
  
  <p>Only 2 lines are there. First classify and then predict. </p>
  
  <pre><code>&gt; classifier&lt;-naiveBayes(iris[,1:4], iris[,5]) 
  &gt; table(predict(classifier, iris[,-5]), iris[,5])
  </code></pre>
  
  <p>This same code on "iris dataset" working fine. But when i applied the same on my dataset, I am getting some errors.</p>
  
  <p>My dataset contains 4 attributes and 4th attribute the class attribute. </p>
  
  <pre><code>&gt; str(data1)
  'data.frame':   1370 obs. of  4 variables:
   $ TenScore     : num  85 84.2 67.2 91.5 79.3 ...
   $ TwelthScore  : num  69 87.9 67.5 82.7 72.4 ...
   $ GDegreeScore : num  63.3 70.7 61.3 78.2 62.1 ...
   $ Got_Admission: chr  "No" "No" "No" "No" ...
  </code></pre>
  
  <p>So, I tried this.</p>
  
  <pre><code>&gt; classifier&lt;-naiveBayes(data1[,1:3], data1[,4]) 
  &gt; table(predict(classifier, data1[,-4]), data1[,4])
  Error in table(predict(classifier, data1[, -4]), data1[, 4]) : 
    all arguments must have the same length
  </code></pre>
  
  <p>I am getting above error when I am executing the command. When I just use predict, its giving me following output.</p>
  
  <pre><code>&gt; predict(classifier, data1[,-4])
  factor(0)
  Levels:
  
  str(data1) 'data.frame': 1370 obs. of 4 variables: 
  $ TenScore : num 85 84.2 67.2 91.5 79.3 ... 
  $ TwelthScore : num 69 87.9 67.5 82.7 72.4 ... 
  $ GDegreeScore : num 63.3 70.7 61.3 78.2 62.1 ... 
  $ Got_Admission: chr "No" "No" "No" "No" ...
  </code></pre>
  
  <p>Please explain me whats the errors about and how to solve?</p>