Caret + RStudio: Error "Please make sure `y` is a factor or numeric value" when training
Have you done any pre-processing or data manipulation before training the model?

Its hard for me to say what is the reason the error, but I have tried to do the same task and it worked whithout errors, here is my code:

library(mlbench)
library(caret)
df &lt;- PimaIndiansDiabetes

#Using x, y arguments

modelo &lt;- train(x = df[, 1:8] , y = df$diabetes, method='mlp') 

#Using formula
modelo &lt;- train(diabetes ~.,  data = df, method='mlp') 


Both approaches valid, and produce result like this:

&gt; modelo &lt;- train(x = df[, 1:8] , y = df$diabetes, method='mlp')
&gt; modelo
Multi-Layer Perceptron 

768 samples
  8 predictor
  2 classes: 'neg', 'pos' 

No pre-processing
Resampling: Bootstrapped (25 reps) 
Summary of sample sizes: 768, 768, 768, 768, 768, 768, ... 
Resampling results across tuning parameters:

  size  Accuracy   Kappa        
  1     0.6545936   0.0000000000
  3     0.6416382  -0.0008031577
  5     0.6397277   0.0002662915

Accuracy was used to select the optimal model using the largest value.
The final value used for the model was size = 1.


Please note that your results might differ a little.