Roxygen、包构建和使用。Rd2=TRUE
我有一个简单的 shell 脚本,用于构建我的 Roxygen 文档、构建包、检查,然后在我的计算机上安装新构建的包。这很简单:
#! /bin/sh
R CMD roxygen -d myPackage
R CMD build myPackage/
R CMD check myPackage_0.01.tar.gz
R CMD INSTALL myPackage myPackage_0.01.tar.gz
但是我在 Roxygen 获取 .onLoad() 函数时遇到了问题,如 之前在 StackOverflow 上描述的。解决方案是将 use.Rd2=TRUE 选项与 roxygenize 结合使用。好吧,我想从命令提示符构建,所以我将此行更改
R CMD roxygen -d myPackage
为以下行,通过标准输入将 roxygenize 行推送到 R:
echo 'require("roxygen"); roxygenize("myPackage", roxygen.dir="myPackage",
copy.package=FALSE, use.Rd2=TRUE)' | R --no-save < /dev/stdin
这似乎工作得很好。但感觉有点绕。有没有更简单和/或更优雅的方法?
I have a simple shell script that builds my Roxygen documents, builds the package, checks, then installs the newly built package on my machine. It's quite simple:
#! /bin/sh
R CMD roxygen -d myPackage
R CMD build myPackage/
R CMD check myPackage_0.01.tar.gz
R CMD INSTALL myPackage myPackage_0.01.tar.gz
But I'm having issues with Roxygen picking up my .onLoad() function as described previously on StackOverflow. The solution is to use the use.Rd2=TRUE option with roxygenize. Well I want to build from the command prompt so I changed this line
R CMD roxygen -d myPackage
to the following line which shoves a roxygenize line to R through the stdin:
echo 'require("roxygen"); roxygenize("myPackage", roxygen.dir="myPackage",
copy.package=FALSE, use.Rd2=TRUE)' | R --no-save < /dev/stdin
This seems to work just dandy. But it feels a little convoluted. Is there an easier and/or more elegant way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我做了类似的事情,但我在 shell 脚本中使用了 HERE 文档,以使其看起来更干净。
R 代码与 R CMD roxygen 期间运行的脚本中的代码非常相似。
我的系统上安装的 roxygen(版本 0.1;本周从 CRAN 安装)似乎不支持上面提到的
-s
选项...I do something similar, but I use a HERE document in the shell script to make it look cleaner.
The R code is very similar to that in the script run during
R CMD roxygen
.The roxygen that is installed on my system (version 0.1; installed from CRAN this week) doesn't seem to support the
-s
option mentioned above...可能 R CMD roxygen -s 选项在这里会有帮助。我相信它实际上与在
roxygenize
函数中设置use.Rd2=TRUE
相同。May be the
R CMD roxygen -s
option will help here. I believe it is effectively the same as settinguse.Rd2=TRUE
in theroxygenize
function.