[R] Conditional inference forest error: levels in factors do not match

Ana Davidson davidson at unm.edu
Fri Dec 7 20:51:31 CET 2012

#Conditional inference forest ("Party" package) error message states 
that levels in factors of new data do not match original data, but they 

#create conditional inference forest
oc_listed.fit1 <- cforest(Listed~ 
HabMode,controls=cforest_unbiased(ntree=500), data=oc.complete)

#use predict function for subset of data
#this works correctly

#use predict on new set of data
#produces this error message

#Error in checkData(oldData, RET) :
   #Levels in factors of new data do not match original data

#We can show that all of the levels match
table(DD_NOT$ORD %in% oc.complete$ORD)

#same check
sum(!levels(DD_NOT$ORD) %in% levels(oc.complete$ORD))

#equals 0, all levels are the same.

#Then why does it fail?



More information about the R-help mailing list