error using random forest
1
0
Entering edit mode
Salwa Eid ▴ 100
@salwa-eid-5104
Last seen 9.6 years ago
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]]
• 1.9k views
ADD COMMENT
0
Entering edit mode
@martin-morgan-1513
Last seen 6 weeks ago
United States
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
ADD COMMENT

Login before adding your answer.

Traffic: 752 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6