[R] Need help with error
Savitri N Appana
snappa01 at louisville.edu
Mon Mar 21 18:37:55 CET 2011
Thank you for your suggestion Allan. I should have paid attention to
the posting instructions.
Pls find below the sample code from the ?splsda in the caret package.
Note: It used to work fine in R v2.8.1, but this error shows up now,
given that I've modified the code on how the splsda or predict.splsda
functions are called, i.e. as caret:::splsda and caret:::predict.splsda
b/c I am running R v2.12.1 now.
######## sample code below..
library(caret)
data(mdrr)
set.seed(1)
inTrain <- sample(seq(along = mdrrClass), 450)
nzv <- nearZeroVar(mdrrDescr)
filteredDescr <- mdrrDescr[, -nzv]
training <- filteredDescr[inTrain,]
test <- filteredDescr[-inTrain,]
trainMDRR <- mdrrClass[inTrain]
testMDRR <- mdrrClass[-inTrain]
preProcValues <- preProcess(training)
trainDescr <- predict(preProcValues, training)
testDescr <- predict(preProcValues, test)
splsFit <- caret:::splsda(trainDescr, trainMDRR,
K = 5, eta = .9,
probMethod = "Bayes")
>splsFit### ERROR is HERE!!!!
Error in switch(classifier, logistic = { : EXPR must be a length 1
vector
confusionMatrix(
caret:::predict.splsda(splsFit, testDescr),
testMDRR)
########
Again, thank you in advance for any explanation re the error.
Best,
Savi
>>> Allan Engelhardt 03/19/11 4:24 AM >>>
As it says at the bottom of every post:
> PLEASE do read the posting
guidehttp://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
Without an example that fails, it is hard to help.
Allan
On 18/03/11 16:26, Savitri N Appana wrote:
> Hi R users,
>
> I am getting the following error when using the splsda function in R
> v2.12.1:
>
> "Error in switch(classifier, logistic = { : EXPR must be a length 1
> vector"
>
> What does this mean and how do I fix this?
>
> Thank you in advance!
>
> Best,
> Savi
>
> ______________________________________________
> 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.
More information about the R-help
mailing list