Take the 2-minute tour ×

I am attempting a random forest on some data where the class variables is binary (either 1 or 0). Here is the code I'm running:

forest.model <- randomForest(x = ticdata2000[,1:85], y = ticdata2000[,86], 

But when the forest gets to the end, I get the following error:

Warning message:
In randomForest.default(x = ticdata2000[, 1:85], y = ticdata2000[,  :

The answer, of course, is no. I don't want to do regression. I have a single, discrete variable that only takes on 2 classes. Of course, when I run predictions with this model, I get continuous numbers, when I want a list of zeroes and ones. Can someone tell me what I'm doing wrong to get this to use regression and not classification?


share|improve this question

1 Answer 1

up vote 5 down vote accepted

Change your response column to a factor using as.factor (or just factor). Since you've stored that variable as numeric 0's and 1's, R rightly interprets it as a numeric variable. If you want R to treat it differently, you have to tell it so.

This is mentioned in the documentation under the y argument:


share|improve this answer
thanks, Joran, it worked great. –  Eric Jun 16 '13 at 23:50

Your Answer


