首页 > 解决方案 > 尽管没有错误,但缺少晕影输出

问题描述

我正在用这个小插图标题写一个 R 包:

---
title: "Adaptive non-parametric learning"
author: "..."
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Adaptive non-parametric learning}
  %\VignetteEngine{knitr::rmarkdown_notangle}
  %\VignetteEncoding{UTF-8}
---

我添加rmarkdown_notangle以避免在 CRAN 上运行小插图,因为完整的小插图将需要一个小时才能运行(即使现在我正在测试并且需要 2 分钟)。

我编译包:

Rscript -e "devtools::document();devtools::check();devtools::build();devtools::install();"

输出显示:

...
─  installing the package to build vignettes
✔  creating vignettes (1m 48.8s)
...
✔  checking files in ‘vignettes’ ...
...
✔  checking for unstated dependencies in vignettes ...
✔  checking package vignettes in ‘inst/doc’
✔  checking re-building of vignette outputs (1m 47.9s)
...
─  installing the package to build vignettes
✔  creating vignettes (1m 49.5s)
...
** installing vignettes
** testing if installed package can be loaded
* DONE (PosteriorBootstrap)
Reloading attached PosteriorBootstrap

但是doc/目录是空的,inst/doc目录不存在,当我导入包时,没有安装小插曲:

> library(PosteriorBootstrap)
> browseVignettes(package="PosteriorBootstrap")
No vignettes found by browseVignettes(package = "PosteriorBootstrap")
> vignette("Adaptive Non-parametric learning")
Warning message:
vignette ‘Adaptive Non-parametric learning’ not found

我发现这个线程建议使用%\VignetteEngine{knitr::rmarkdown},我使用和install_github(..., build_vignettes=TRUE),因为我在本地构建它,所以我不使用它。

小插曲输出在哪里?

标签: rdevtools

解决方案


One solution is to change the default build_vignettes = FALSE in devtools::install():

devtools::install(build_vignettes = TRUE)

Then do browseVignettes(package = "package_name") to show the vignettes, e.g. on a browser if you use R on the command line.

I found the solution from a comment in the thread I quoted, which suggested the same solution for devtools::install_github().

I could not find the vignette output created by devtools::check() and devtools::build().


推荐阅读