This question is similar to some other questions about Stackoverflow ( here , here and here ), but still enough so that I cannot extrapolate these answers to my case.
I have a function in which I approach the C5.0 model, rather than trying to build a model.
train_d <- globald[train_ind,c(features,21)] model <- C5.0(binclass ~ .,data=train_d,trials=10)
binclass is the column name in my training / test data (globald is the data framework from which I multiply rows with _ind indices and c(3:12,21) columns c(3:12,21) , where column 21 is called binclass ). Installation works well. However, when I also add the line
plot(model,trial=0)
then I get the following error: Error in is.data.frame(data) : object 'train_d' not found .
How is it possible that train_d found and used correctly when fitting the model, but train_d nowhere to be found when plotting? And any suggestion on how to solve this problem. The namespaces in [r] remain a mystery to me.
An example of a minimal run is as follows:
f <- function(){ library(C50) set.seed(1) class = c(1,2) d <- data.frame(feature1 = sample(1:10,10,replace=TRUE), feature2 = 1:10, binclass = class) d$binclass <- as.factor(d$binclass) model <- C5.0(binclass ~ ., data=d) plot(model) }
Calling f() results in the following error: Error in is.data.frame(data) : object 'd' not found
Edit: According to the answer from MrFlick, it seems that the cause of this problem is a bug in the C5.0 code. There are some workarounds that Pascal and Mr. Flick point to.