The following code crashes, for no reason I can distinguish.
library(caret) data(iris) TrainData <- iris[,1:4] TrainClasses <- factor(ifelse(iris[,5]=='versicolor','versicolor','other')) model1 <- train(TrainData,TrainClasses,method='glmnet')
With the following error:
Error in { : task 1 failed - "'n' must be a positive integer >= 'x'"
If sub in another model, for example glm
, it works fine. If I use 3 classes, TrainClasses <- iris[,5]
, it also works fine.
What about the two classes uniquely causes the glmnet method to fail?
This is version R of version 2.14.0, version 5.09-006 with a carriage, on the windows. The same error occurs on both my mac and linux.
source share