title: Error in predictions$class : $ operator is invalid for atomic vectors
body: <p>I am trying to use the Naive Bayes method on my own data, which predicts a diagnosis for breast cancer based upon 9 features. I'm trying to use a 70% training data and 30% testing data.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>&gt; BCD &lt;- read.csv("H:/BCD.csv")
  &gt;   View(BCD)
  &gt; trainIndex &lt;- createDataPartition(BCD$Diagnosis, p=0.70, list=FALSE)
  &gt; data_train &lt;- BCD[ trainIndex,]
  &gt; data_test &lt;- BCD[-trainIndex,]
  #train a naive bayes model
  &gt; model &lt;- naiveBayes(Diagnosis~., data=data_train)
  #make predictions
  &gt; predictions &lt;- predict(model, data_test[,1:9])
  #summarize results
  &gt; confusionMatrix(predictions$class, data_test$Diagnosis)
  </code></pre>
  
  <p>I'm getting the following error:</p>
  
  <pre><code>Error in predictions$class : $ operator is invalid for atomic vectors
  </code></pre>
  
  <p>Any idea what this means or how I can fix it?</p>
  
  <p>Here's a sample of my data that will hopefully help:</p>
  
  <pre><code>&gt; dput(head(BCD))
  structure(list(Clump.Thickness = c(5L, 5L, 3L, 6L, 4L, 8L), Uniformity.of.Cell.Size = c(1L, 
  4L, 1L, 8L, 1L, 10L), Uniformity.of.Cell.Shape = c(1L, 4L, 1L, 
  8L, 1L, 10L), Marginal.Adhesion = c(1L, 5L, 1L, 1L, 3L, 8L), 
      Single.Epithelial.Cell.Size = c(2L, 7L, 2L, 3L, 2L, 7L), 
      Bare.Nuclei = c(1L, 10L, 2L, 4L, 1L, 10L), Bland.Chromatin = c(3L, 
      3L, 3L, 3L, 3L, 9L), Normal.Nucleoli = c(1L, 2L, 1L, 7L, 
      1L, 7L), Mitoses = c(1L, 1L, 1L, 1L, 1L, 1L), Diagnosis = c(1L, 
      1L, 1L, 1L, 1L, 2L)), .Names = c("Clump.Thickness", "Uniformity.of.Cell.Size", 
  "Uniformity.of.Cell.Shape", "Marginal.Adhesion", "Single.Epithelial.Cell.Size", 
  "Bare.Nuclei", "Bland.Chromatin", "Normal.Nucleoli", "Mitoses", 
  "Diagnosis"), row.names = c(NA, 6L), class = "data.frame")
  </code></pre>