Using ROCR package difficulties

r glm
user2474671 picture user2474671 · Jun 11, 2013 · Viewed 10.8k times · Source

I'm following an analysis of German Credit data and I got an error which I'm failing to rectify because I already installed the ROCR package. Below is the code that uses the ROCR:

#load library
library(ROCR)

#score test data set
test$score <- predict(m,type='response',test)
pred <- prediction(test$score,test$good_bad)
perf <- performance(pred,"tpr","fpr")
plot(perf)

Now, after running pred, I get the following error:

>pred <- prediction(test$score,test$Good_Bad)
Error: could not find function "prediction".

This also happens when I try to execute the following line:

>perf <- performance(pred,"tpr","fpr")
Error: could not find function "performance"

Answer

Shery picture Shery · Apr 4, 2014

I had the same issue... If you look closely, it says:

Loading required package: gplots
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
  there is no package called ‘KernSmooth’
In addition: Warning messages:
1: package ‘ROCR’ was built under R version 3.0.3 
2: package ‘gplots’ was built under R version 3.0.3 
Error: package ‘gplots’ could not be loaded

I simply installed the install.packages("gplots") and then loaded the library and it loaded and found the function without any issues.

Hope this helps