开发者

Roxygen, package building, and use.Rd2=TRUE

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.开发者_JAVA百科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?


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜