R random forest : data (x) has 0 rows -


i using randomforest function randomforest package find important variable: dataframe called urban , response variable revenue numeric.

urban.random.forest <- randomforest(revenue ~ .,y=urban$revenue, data = urban, ntree=500,    keep.forest=false,importance=true,na.action = na.omit) 

i following error:

error in randomforest.default(m, y, ...) : data (x) has 0 rows 

on source code related x variable:

n <- nrow(x) p <- ncol(x) if (n == 0)  stop("data (x) has 0 rows") 

but cannot understand x.

i solved that. had columns values na or same. dropped them , went ok. columns classes character, numeric , factor.

 candidatesnodata.index <- c()  (j in (1 : ncol(dataframe)))   {     if (    is.numeric(dataframe[ ,j])  &  length(unique(as.numeric(dataframe[ ,j]))) == 1      )      {candidatesnodata.index <- append(candidatesnodata.index,j)}                                 }  dataframe <- dataframe[ , - candidatesnodata.index] 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -