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.

Here's my code:

```
> BCD <- read.csv("H:/BCD.csv")
>   View(BCD)
> trainIndex <- createDataPartition(BCD$Diagnosis, p=0.70, list=FALSE)
> data_train <- BCD[ trainIndex,]
> data_test <- BCD[-trainIndex,]
#train a naive bayes model
> model <- naiveBayes(Diagnosis~., data=data_train)
#make predictions
> predictions <- predict(model, data_test[,1:9])
#summarize results
> confusionMatrix(predictions$class, data_test$Diagnosis)

```

I'm getting the following error:

```
Error in predictions$class : $ operator is invalid for atomic vectors

```

Any idea what this means or how I can fix it?

Here's a sample of my data that will hopefully help:

```
> 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")

```