我需要通过bash shell运行几个脚本,Rscript并且我使用的一些函数需要该函数isGeneric.但是,在这种情况下,流程就像那样(例如):
Error in .getLogLik() : could not
find function "isGeneric"
Calls: main -> dredge -> .getLik -> .getLogLik
Execution halted
Run Code Online (Sandbox Code Playgroud)
这可以如下再现
# in the bash shell
echo "isGeneric('apply')" > /tmp/test.R
Rscript /tmp/test.R
Run Code Online (Sandbox Code Playgroud)
结果:
Error: could not find function "isGeneric"
Execution halted
Run Code Online (Sandbox Code Playgroud)
但是,如果我们打开一个R会话并键入以下内容,它的工作原理如下:
# in the R shell
isGeneric('apply')
[1] FALSE
Run Code Online (Sandbox Code Playgroud)
你知道问题的来源以及如何解决吗?
Jos*_*ich 23
根据help(Rscript),Rscript默认情况下不加载方法包,因为它很耗时.所以你要么在命令行上指定它:
Rscript --default-packages=methods file.R
Run Code Online (Sandbox Code Playgroud)
或者library(methods)在你正在调用的文件的顶部.
| 归档时间: |
|
| 查看次数: |
4391 次 |
| 最近记录: |