我正在构建一个R包。
我在vignettes/mydoc.Rmd
处有一个rmarkdown文件。
使用devtools::build_vignettes()
会导致文件显示在inst/doc
。
使用R CMD build .
时,不会出现任何警告或错误。
但是,当我在R中使用vignette()
时,我看不到该包的任何插图。
我的DESCRIPTION
文件包含:
Suggests: knitr,
rmarkdown,
VignetteBuilder: knitr
答案 0 :(得分:4)
It's not clear how/if you're installing in between steps. I'll quote from Hadley's R Packages website, the Vignettes chapter, mostly from the Development Cycle section:
To create your first vignette, run:
devtools::use_vignette("my-vignette") This will:
Create a vignettes/ directory.
Add the necessary dependencies to DESCRIPTION (i.e. it adds knitr to the Suggests and VignetteBuilder fields).
Draft a vignette, vignettes/my-vignette.Rmd.
The above can be done manually or via the use_vignette()
command, but it does need to be done.
After authoring your vignette, it will need to be built.
You can build all vignettes from the console with
devtools::build_vignettes()
, but this is rarely useful. Instead usedevtools::build()
to create a package bundle with the vignettes included. RStudio’s "Build & reload" does not build vignettes to save time. Similarly,devtools::install_github()
(and friends) will not build vignettes by default because they’re time consuming and may require additional packages. You can force building withdevtools::install_github(build_vignettes = TRUE)
. This will also install all suggested packages.
I believe that devtools::install()
will include any vignettes that are already built, the extra argument is only needed if you want rebuild them at the time of installation.
R CMD BUILD
makes a tarball, it doesn't modify your development directories, and R CMD INSTALL
installs the package in your library, it also doesn't modify your development directories.
For development you can use just devtools::install(..., build_vignettes = T)
when you want to rebuild vignettes and install a package.
You really only need to build the package itself (generate zip or tarball depending on your system) when you're ready to release to CRAN. At that point, I'd use devtools::build(..., vignettes = T)
as a wrapper for R CMD BUILD
, but that's just a preference.
答案 1 :(得分:1)
我一直在经历非常不稳定的行为
R CMD build myPackage
R CMD INSTALL myPackage
有时这会安装小插曲,有时不会。
devtools::install(build_vignettes = TRUE) 似乎是一个更强大的替代方案。它还具有提供更新安装中涉及的任何过时软件包的优势。