Error in Model with caret Package
Please read carefully caret::train since S3 method for class formula is slightly different than default S3 method for caret::train (and takes different arguments)

This should do the work:

model &lt;- caret::train(y = traing$TargetBuy, x = traing[, colnames(traing) != 'TargetBuy'], trControl = train_control, method = "nb")


You can also use model.matrix, but then you need to remember that it removes missing values. See this post for solution:

model &lt;- caret::train(y = factor(traing$TargetBuy), x = model.matrix(TargetBuy ~ ., data = traing), trControl = train_control, method = "nb")