[R] Random Forest Reading N/A's, I don't see them

R. Michael Weylandt <michael.weylandt@gmail.com> michael.weylandt at gmail.com
Thu Dec 15 21:02:18 CET 2011


Use str() on your object and attach the result. For even faster help, use dput() on a *small* sample of your data to make the problem reproducible. 

My guess is that there are characters or, less likely, factors lurking about...

Michael

On Dec 15, 2011, at 2:39 PM, Lost in R <michael.hartye at principiscapital.com> wrote:

> After checking the original data in Excel for blanks and running Summary(cm3)
> to identify any null values in my data, I'm unable to identify an instances.
> Yet when I attempted to use the data in Random Forest, I get the following
> error. Is there something that Random Forest is reading as null which is not
> actually null? Is there a better way to check for this?
> 
>> library(randomForest)
>> system.time(
> + rf1 <- randomForest(as.matrix(cm3[,c(2:length(colnames(cm3)))]),
> + cm3[,1],data=cm3,ntree=50)
> + )
> *Error in randomForest.default(as.matrix(cm3[, c(2:length(colnames(cm3)))]), 
> : 
>  NA/NaN/Inf in foreign function call (arg 1)
> In addition: Warning message:
> In storage.mode(x) <- "double" : NAs introduced by coercion
> Timing stopped at: 1.33 0.01 1.35 *
> 
> 
> Thanks in advance,
> Mike
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/Random-Forest-Reading-N-A-s-I-don-t-see-them-tp4201546p4201546.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list