caret-machine-learning icon indicating copy to clipboard operation
caret-machine-learning copied to clipboard

caret Error in UseMethod("R2")

Open tobigithub opened this issue 9 years ago • 0 comments

Using R2 from caret with a number of packets results in the following name space related error:

> R2(p2[[1]]$value, test_y)
Error in UseMethod("R2") : 
  no applicable method for 'R2' applied to an object of class "c('double', 'numeric')"

Solution

# instead of 
R2(p2[[i]]$value, test_y)
better use double colon and caret name space
caret::R2(p2[[i]]$value, test_y)

Also see https://stat.ethz.ch/R-manual/R-devel/library/base/html/ns-dblcolon.html

Error happens when using caret 0.58 with

m <- c("avNNet", "bagEarth", "bagEarthGCV", 
"bayesglm", "bdk", "blackboost","brnn", "BstLm" , 
"bstTree", "cforest", "ctree", "ctree2", "cubist", 
"dnn", "earth", "elm", "enet",  
"extraTrees",  "gamLoess",  "gaussprLinear", "gaussprPoly", "gaussprRadial", 
"gcvEarth","glm", "glmboost", "glmnet", "icr", "kernelpls", 
"kknn", "knn",  "krlsRadial", "lars" , "lasso", 
"leapBackward", "leapForward", "leapSeq", "lm", "M5", "M5Rules", 
"mlpWeightDecay"  , "partDSA", 
"pcaNNet", "pcr", "penalized", "pls", "plsRglm", "ppr", 
"qrf" , "ranger",  "rf",
"ridge", "rknn" , "rlm", "rpart", "rpart2", "rqlasso", 
"rqnc", "RRF", "RRFglobal",  "rvmPoly", "rvmRadial", 
"simpls", "spls", "superpc" , 
"svmLinear", "svmLinear2", "svmPoly", "svmRadial", "svmRadialCost", 
"treebag", "widekernelpls" , "xgbLinear", 
"xgbTree", "xyf")

tobigithub avatar Dec 24 '15 03:12 tobigithub