문제

I have simple R script which trying to Define class. example.R

 Tuple <- setClass("Tuple",
            slots = c(
              id="character",
              comp="character",
              stream="character",
              task="character",
              output="vector",
              anchors="vector"
                )
            );

when i run Rscript example.R . i am getting an error saying below

Error in eval(expr, envir, enclos) : could not find function "setClass" Calls: source -> withVisible -> eval -> eval

can any one help?

도움이 되었습니까?

해결책

Rscript, in all its wisdom, does not load the standard methods package. So precede your script with

library(methods)

and all should be good.

If you're on Linux, you could use our littler package. It loads methods for you too, and starts a little faster than Rscript too.

Edit It is now some five years later and this has been added to Rscript in R release 3.5.0 or later.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top