Shahzad
Shahzad

Reputation: 2049

Adabag package in R

I am trying to perform classification using R's adabag package.

The following call works perfectly with R's ada package's ada() function.

model<-ada(factor(label)~., data=trainingdata)

But when the same training data set is used in the following adabag's function call, it returns an error:

model<-boosting(factor(label)~., data=trainingdata)

Error in `[.data.frame`(data, , as.character(formula[[2]])) : 
undefined columns selected

What this error suggests exactly?

Upvotes: 5

Views: 5292

Answers (2)

Bruno Nunes
Bruno Nunes

Reputation: 1

I get the same error when using adabag package, it seems that there are some incompatible names for columns that we can't use for modelling.

I ran the expression:

colnames(Dataset) <- make.names(colnames(Dataset))

and it worked for me.

Upvotes: 0

IRTFM
IRTFM

Reputation: 263471

I get exactly that error message when running a minor modification of boosting's first example:

> data(iris)
> iris.adaboost <- boosting(factor(Species)~., data=iris, boos=TRUE, mfinal=10)
Error in `[.data.frame`(data, , as.character(formula[[2]])) : 
  undefined columns selected

So you should try the advice I just gave in a comment (to do the factor()-ing beforehand). The formula interface to boosting is not full featured enough to even handle the factor function in its parse-tree.

Upvotes: 4

Related Questions