Warning message in randomForest I want to applicate the randomForest to my data for predicting target variable, but I have got a warnings message saying:

Warning message:
In randomForest.default(m, y, ...) :
  The response has five or fewer unique values.  Are you sure you want to do regression?


I didn't know what was going on?

this is my code:

library(randomForest)
M=data.frame(Type_peau,PEAU_CORPS,SENSIBILITE,IMPERFECTIONS,BRILLANCE ,GRAIN_PEAU,RIDES_VISAGE,ALLERGIES,MAINS,
             INTERET_ALIM_NATURELLE,INTERET_ORIGINE_GEO,INTERET_VACANCES,INTERET_COMPOSITION,DataQuest1,Priorite2,
             Priorite1,DataQuest4,Age,Nbre_gift,w,Achat_client)

factor_vars &lt;- c("Type_peau","PEAU_CORPS","SENSIBILITE","IMPERFECTIONS","BRILLANCE","GRAIN_PEAU",
                 "RIDES_VISAGE","ALLERGIES","MAINS","INTERET_ALIM_NATURELLE","INTERET_ORIGINE_GEO",
                 "INTERET_VACANCES","INTERET_COMPOSITION","DataQuest1","Priorite2","Priorite1","DataQuest4")

head(M)
str(M)

sample.ind &lt;- sample(2, nrow(M), replace = T,prob = c(0.6,0.4))
cross.sell.dev &lt;- M[sample.ind==1,]
cross.sell.val &lt;- M[sample.ind==2,]

table(cross.sell.dev$Achat_client)/nrow(cross.sell.dev)

table(cross.sell.val$Achat_client)/nrow(cross.sell.val)

varNames &lt;- names(M)
# Exclude ID or Response variable
varNames &lt;- varNames[!varNames %in% c("Achat_client")]

# add + sign between exploratory variables
varNames1 &lt;- paste(varNames, collapse = "+")

# Add response variable and convert to a formula object
rf.form &lt;- as.formula(paste("Achat_client", varNames1, sep = " ~ "))

test$Variable1 &lt;- factor(test$Variable1,levels=levels(train$Varialbe1))

# Buiding 
cross.sell.rf &lt;- randomForest(rf.form,cross.sell.dev,ntree=500,importance=T)
plot(cross.sell.rf)


Thanks for your help!
In fact, the problem was in the type of target variable.

It should be assumed as factor and not numeric !!

So the solution is just to did like that after reading table:

Achat_client=as.factor(Achat_client)


Good Luck!