无法从 Rscript 批处理文件调用 roxygenize 函数
我正在编写一个使用 roxygen2 来自动 roxygenize 我的包的脚本。我希望它是可执行的,以便它可以成为更大脚本的一部分来准备和安装包,但由于某种原因我无法使其与 Rscript 一起使用。
代码如下:
#!/usr/bin/env Rscript
library(roxygen2)
roxygenize('.', copy=FALSE)
如果我启动交互式 R 会话或者使用 R CMD BATCH 提交代码,则该代码可以正常工作。但是,如果我通过 Rscript 直接将脚本作为可执行文件运行,我会得到此输出和错误(并且无论脚本是否位于当前目录或 bin 中,我都会得到错误)。
bin/roxygenize.R
Loading required package: digest
Warning message:
package 'roxygen2' was built under R version 2.13.2
Error in parse.files(r_files) : could not find function "setPackageName"
Calls: roxygenize -> parse.files
Execution halted
看起来 setPackageName 在基本 R 中,所以我不明白为什么它不在那里。此外,我在许多其他情况下使用 Rscript,这似乎是它唯一失败的地方。
非常感谢任何帮助。
I am writing a script that uses roxygen2 to automatically roxygenize my package. I'd like it to be executable so that it can be part of a larger script to prepare and install the package, but I cannot make it work with Rscript for some reason.
Here is the code:
#!/usr/bin/env Rscript
library(roxygen2)
roxygenize('.', copy=FALSE)
This works correctly if I start an interactive R session or if I submit the code using R CMD BATCH. However, I get this output and error if I run the script directly as an executable via Rscript (and I get the error regardless of whether the script is in the current directory or bin).
bin/roxygenize.R
Loading required package: digest
Warning message:
package 'roxygen2' was built under R version 2.13.2
Error in parse.files(r_files) : could not find function "setPackageName"
Calls: roxygenize -> parse.files
Execution halted
It looks like setPackageName is in base R, so I can't figure out why it's not there. Additionally, I use Rscript in lots of other situations and this seems to be the only place that it fails.
Any help is much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在加载
roxygen2
和调用roxygenize()
之前显式加载包methods
和utils
。Explicitly load the packages
methods
andutils
before loadingroxygen2
and callingroxygenize()
.