I am using randomForest function from randomForest package to find the most important variable: my dataframe is called urban and my response variable is revenue which is numeric.
urban.random.forest <- randomForest(revenue ~ .,y=urban$revenue, data = urban, ntree=500, keep.forest=FALSE,importance=TRUE,na.action = na.omit) I get the following error:
Error in randomForest.default(m, y, ...) : data (x) has 0 rows on the source code it is related to x variable:
n <- nrow(x) p <- ncol(x) if (n == 0) stop("data (x) has 0 rows") but I cannot understand what is x.
randomForestyou shouldn't pass theyvalue again, because then the function assumes that the formula is thexvalue and things go wrong.urban.random.forest <- randomForest(Species ~ ., data=iris, ntree=500, keep.forest = FALSE,importance = TRUE, na.action = na.omit)