Roxygen, package creation and use. Rd2 = TRUE

I have a simple script shell that builds my Roxygen documents, builds a package, validates, and then installs a newly created package on my computer. It is pretty 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 am having problems with Roxygen, which executes my .onLoad () function as https://stackoverflow.com/a/167272/2 . The solution is to use the use.Rd2 = TRUE option with roxygenize. Well, I want to build from the command line, so I changed this line

R CMD roxygen -d myPackage 

to the next line, which forces the roxygenize line to R via stdin:

echo 'require("roxygen"); roxygenize("myPackage", roxygen.dir="myPackage",
   copy.package=FALSE, use.Rd2=TRUE)' | R --no-save < /dev/stdin

This one seems to work only dandy. But he feels a little confused. Is there an easier and / or more elegant way?

+3
2

- , script, .

#!/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 script R CMD roxygen.

, ( 0.1, CRAN ), , -s, ...

+2

, R CMD roxygen -s . , , use.Rd2=TRUE roxygenize.

+2

Source: https://habr.com/ru/post/1779037/


All Articles