Roxygen、包构建和使用。Rd2=TRUE

发布于 2024-10-06 08:40:52 字数 748 浏览 1 评论 0原文

我有一个简单的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜`诱少女 2024-10-13 08:40:52

我做了类似的事情,但我在 shell 脚本中使用了 HERE 文档,以使其看起来更干净。

#!/bin/sh
##
##
## Must be run from the parent of the package directory (no options
## to change target of check or tarball!?!)

PACKAGE="analyzeNMON"
VERSION=$(awk -F": +" '/^Version/ { print $2 }' ${PACKAGE}/DESCRIPTION)

R --no-restore --slave <<EOR
  library(roxygen)
  roxygenize(package.dir="${PACKAGE}",
             roxygen.dir="${PACKAGE}",
             use.Rd2=TRUE,
             overwrite=TRUE,
             copy.package=FALSE,
             unlink.target=FALSE)
EOR

R CMD build ${PACKAGE}
R CMD check ${PACKAGE}_${VERSION}.tar.gz
R CMD INSTALL ${PACKAGE}_${VERSION}.tar.gz

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.

#!/bin/sh
##
##
## Must be run from the parent of the package directory (no options
## to change target of check or tarball!?!)

PACKAGE="analyzeNMON"
VERSION=$(awk -F": +" '/^Version/ { print $2 }' ${PACKAGE}/DESCRIPTION)

R --no-restore --slave <<EOR
  library(roxygen)
  roxygenize(package.dir="${PACKAGE}",
             roxygen.dir="${PACKAGE}",
             use.Rd2=TRUE,
             overwrite=TRUE,
             copy.package=FALSE,
             unlink.target=FALSE)
EOR

R CMD build ${PACKAGE}
R CMD check ${PACKAGE}_${VERSION}.tar.gz
R CMD INSTALL ${PACKAGE}_${VERSION}.tar.gz

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...

冷︶言冷语的世界 2024-10-13 08:40:52

可能 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 setting use.Rd2=TRUE in the roxygenize function.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文