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

David Winsemius dwinsemius at comcast.net
Sat Dec 17 00:44:30 CET 2011


On Dec 15, 2011, at 2:39 PM, Lost in R 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(

# Are you aware of the effect of using as.matrix(..) on the storage  
mode?

> cm3[,c(2:length(colnames(cm3)))]),

# that was the x argument

> + cm3[,1],

# The y variable

> data=cm3,

# That's odd. You already offered the data objects.  I wonder what the  
function will do with that?


> 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

I can see two potential sources of such an error.

> 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.

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list