从命令行运行R脚本时找不到setClass

用户名

我有尝试定义类的简单R脚本。例子

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

当我运行Rscript example.R时。我在下面说一个错误

eval(expr,envir,enclos)中的错误:找不到函数“ setClass”调用:源-> withVisible-> eval-> eval

有人可以帮忙吗?

德克·埃德比布特尔(Dirk Eddelbuettel)

Rscript尽其所能,不会加载标准methods软件包。因此,在脚本之前加上

library(methods)

一切都应该很好。

如果您使用的是Linux,则可以使用我们的littler软件包。它也methods为您加载,并且启动速度也比Rscript快一点。

编辑现在已经过了五年了,并且已经Rscript在R版本3.5.0或更高版本中添加了它。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章