Amy Hessen
2010-Mar-14 10:55 UTC
[R] Error in object$tables[[v]] : subscript out of bounds
Hi, Could you please tell me how I correct the following error message? “Error in object$tables[[v]] : subscript out of bounds” This is the code: library(e1071) data(iris) attach(iris) class_label <- names(iris)[1] myformula <- formula(paste(class_label,"~ .")) mymodel<-naiveBayes(myformula, iris,cross=3) predict(mymodel,iris) ##Error in object$tables[[v]] : subscript out of bounds Cheers, Amy _________________________________________________________________ Link all your email accounts and social updates with Hotmail. Find out now. [[alternative HTML version deleted]]
Uwe Ligges
2010-Mar-14 14:30 UTC
[R] Error in object$tables[[v]] : subscript out of bounds
On 14.03.2010 11:55, Amy Hessen wrote:> > > > Hi, > Could you please tell me how I correct the following error message? > ?Error in object$tables[[v]] : subscript out of bounds? > > This is the code: > > library(e1071) > data(iris) > attach(iris) > class_label<- names(iris)[1]This is not the name for the class variable of the wiris data from R.> myformula<- formula(paste(class_label,"~ ."))Why do you construct this in a so complicated manner rather than typing the formula directly?> mymodel<-naiveBayes(myformula, iris,cross=3)naiveBayes sort of fails (well, it runs smoothly but the result won't make sense) here since it expects a class variable.> predict(mymodel,iris) ##Error in object$tables[[v]] : subscript out of boundsWorks for me. Please upgrade R, e1071 and run in a clean session to see that the code above does not fail. Although it makes absolutely no sense. Uwe Ligges> Cheers, > Amy > _________________________________________________________________ > Link all your email accounts and social updates with Hotmail. Find out now. > > [[alternative HTML version deleted]] > > > > > ______________________________________________ > 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.