title: Error in table "all arguments must have the same length"
body: <p>I'm getting the above error when trying to run my R code (Naive Bayes model using e1071).</p>
  
  <p>1) Setup: I created a csv table with the following six fields:</p>
  
  <pre><code>dep variable    -&gt; cncl_flag: 0,1
  
  indep variables -&gt; Channel:  red, blue, green, black 
                  -&gt; Age:      &lt;1, 1-2, &gt;2
                  -&gt; Cases:    0,1
                  -&gt; Products: product 1, product 2, ... , product 8
                  -&gt; Dollars:  &lt;100, 100-200, ... , &gt;1000
  </code></pre>
  
  <p>2) R Code: Using the table detailed above I run the following R code:</p>
  
  <pre><code>myData&lt;-read.csv("C:/Users/me/Desktop/R/NBC.csv", header = TRUE, sep = ",")
  
  myData[,"train"] &lt;- ifelse(runif(nrow(myData))&lt;0.80,1,0)
  trainColNum &lt;- grep("train",names(myData))
  trainmyData &lt;- myData[myData$train==1,-trainColNum]
  testmyData &lt;- myData[myData$train==0,-trainColNum]
  
  
  library(e1071)
  nb_model &lt;- naiveBayes(cncl_flag~.,data = trainmyData)
  
  summary(nb_model)
  nb_test_predict &lt;- predict(nb_model,testmyData[,-1])
  table(pred=nb_test_predict,true=testmyData$cncl_flag)
  </code></pre>
  
  <p>3) Output: <strong>Error in table(pred = nb_test_predict, true = testmyData$cncl_flag) : all arguments must have the same length</strong></p>
  
  <p>4) What I've tried: I removed all rows containing any "NA" or blank results</p>