`cv.glmnet` works in RStudio but not RScript

后端 未结 2 1434
日久生厌
日久生厌 2020-12-12 05:03

The following commands work fine in RStudio, but not RScript:

require(glmnet)
calibdata = read.csv(\"calibrationfile.csv\")

xs = model.matrix(as.formula(\"t         


        
相关标签:
2条回答
  • 2020-12-12 05:42

    I ran into same issue, and found two possible workaround (just for a complement of @Dirk Eddelbuettel's answer):

    Well, I read somewhere that --default-packages=methods,utils needs to be passed to Rscript to work around this: https://github.com/stan-dev/rstan/issues/190

    OR,

    Also, it seems, Rscript being missing the load of the methods package. This can also be fixed by calling library('methods') at the beginning of your script: https://github.com/dhimmel/elevcan/issues/1.

    Hope this helps.

    0 讨论(0)
  • 2020-12-12 05:55

    RScript has this "lovely" feature of not loading the (base package) methods for you.

    So all you need here is an additional

      require(methods)
    

    or

      suppressMessages(library(methods))
    

    For what it is worth, the littler command-line and scripting front-end to R that Jeff Horner and I wrote defaults to loading methods for you...

    0 讨论(0)
提交回复
热议问题