[BioC] error using random forest

Martin Morgan mtmorgan at fhcrc.org
Mon Mar 5 19:03:56 CET 2012


On 03/05/2012 09:43 AM, Salwa Eid wrote:
>
>
>
>
> Dear all,    Have tried using random forest for classfication and this is the code i wrote exactly: trial.rf<-randomForest(Type ~., data=trial) where Type is a column and determines the type and the trial is the data matrix.  I keep getting this error: Error in eval (exprs, envir, enclos): object '117_at' not found.  Where 117_at is a name of the first column.  I tried removing this column but it gave me the same error for the next column. Any help? Regards,salwa  		 	   		
> 	[[alternative HTML version deleted]]
>

It's usually better to post a complete example, sometimes with 
artificial data that still reproduces the error:


 >   m = matrix(runif(100), nrow=20, dimnames=list(NULL, 1:5))
 >  randomForest(`1`~., data=m)
Error in eval(expr, envir, enclos) : object '2' not found


Knowing that symbols starting with digits need to be treated specially 
to be 'legal' (from section 1.8 of RShowDoc("R-intro")), and guessing 
that randomForest is doing something to associate the data with the 
formula, I tried


 > colnames(m) = paste("x", colnames(m), sep="")
 > randomForest(x1~., data=m)

Call:
  randomForest(formula = x1 ~ ., data = m)
                Type of random forest: regression
                      Number of trees: 500
No. of variables tried at each split: 1

           Mean of squared residuals: 0.0941123
                     % Var explained: -41.17

randomForest documentation says that 'data' should be a data.frame, so 
perhaps I should have

   df = as.data.frame(m)
   randomForest(x1~., data=df)

Martin

> _______________________________________________
> Bioconductor mailing list
> Bioconductor at r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor


-- 
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793



More information about the Bioconductor mailing list