christoph_s
2013-Apr-14 09:37 UTC
[R] script works in Rgui, but failes in Rscript (coords, package 'pROC')
Dearh all,
I have following question: a script (using pROC functions) that works when
run in Rgui, failes when run through rscript.
This is the script:
library(pROC)
hits <- c("T", "D", "T", "D",
"T", "D", "T", "D", "T",
"D", "T", "D", "T",
"D", "T", "D", "T", "D")
score <- c(1.804984e-05, 1.908517e-02, 2.934481e-02, 8.188098e-02,
1.528048e-03, 4.617807e-01, 1.420925e-03, 2.360183e-01, 1.874567e-02,
5.127498e-01, 9.438651e-03, 2.162788e-01, 9.142649e-04, 1.173577e-01,
7.270350e-03, 4.699286e-01, 4.553215e-03, 3.942892e-01)
roc_test <- data.frame (hits, score)
roc1 <- roc(roc_test$hit, roc_test$score, plot = FALSE, smooth = FALSE,
sensitivities = TRUE )
roc.result <- coords(roc1, "best", ret=c("t",
"se", "sp"), as.list = TRUE,
best.method=c("closest.topleft"))
print(roc.result$best$threshold)
# script ends here.
However, executing in the command line
(C:\Progra~1\R\R-2.15.3\bin\Rscript.exe ROC_test.R) gives following errors:
Error in ifelse(is(roc, "smooth.roc"), length(attr(roc,
"roc")$cases), :
could not find function "is"
Calls: coords ... coords.roc -> lapply -> FUN -> coords.roc ->
ifelse
Execution halted
Any ideas? Thanks in advance,
Christoph
--
View this message in context:
http://r.789695.n4.nabble.com/script-works-in-Rgui-but-failes-in-Rscript-coords-package-pROC-tp4664173.html
Sent from the R help mailing list archive at Nabble.com.
peter dalgaard
2013-Apr-14 13:36 UTC
[R] script works in Rgui, but failes in Rscript (coords, package 'pROC')
On Apr 14, 2013, at 11:37 , christoph_s wrote:> ... > However, executing in the command line > (C:\Progra~1\R\R-2.15.3\bin\Rscript.exe ROC_test.R) gives following errors: > Error in ifelse(is(roc, "smooth.roc"), length(attr(roc, "roc")$cases), : > could not find function "is" > Calls: coords ... coords.roc -> lapply -> FUN -> coords.roc -> ifelse > Execution halted > > Any ideas? Thanks in advance,is() is in "methods", so try require(methods). -pd -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
christoph_s
2013-Apr-14 13:52 UTC
[R] script works in Rgui, but failes in Rscript (coords, package 'pROC')
Yes, that was what was missing. Great! Thanks a lot! Best regards, Christoph -- View this message in context: http://r.789695.n4.nabble.com/script-works-in-Rgui-but-failes-in-Rscript-coords-package-pROC-tp4664173p4664182.html Sent from the R help mailing list archive at Nabble.com.