knitr .Rmd渐晕不与vignette()一起出现 [英] knitr .Rmd vignettes do not appear with vignette()
问题描述
在我使用R Studio开发的程序包中,我通过devtools::use_vignette("mydoc.Rnw")
创建小插图,该小插图提供了标准的装饰图案标题,例如
In a package I'm developing with R Studio, I create vignettes via devtools::use_vignette("mydoc.Rnw")
, which gives a standard vignette header like
---
title: "Title"
author: "Michael Friendly"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{Title}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
我已经按照 http://yihui.name/knitr/demo/vignette/中的所有说明进行操作,并且 http://r-pkgs.had.co.nz/vignettes.html .包的CRAN页面上列出了小插曲,但是在加载了该包的R会话中似乎无法访问这些小插曲.
I have followed all the instructions in http://yihui.name/knitr/demo/vignette/ and http://r-pkgs.had.co.nz/vignettes.html. The vignettes are listed on the CRAN page for the package, yet they seem inaccessible in an R session with the package loaded.
> browseVignettes("matlib")
No vignettes found by browseVignettes("matlib")
> library(tools)
> names(vignetteEngine(package = 'matlib'))
Error in getEngine(name, package) :
None of packages ‘matlib’ have registered vignette engines
我知道其他具有knitr
处理的.Rmd小插曲的软件包都可以从该软件包访问,但是无法弄清楚为什么我的不能.
什么不见了?
I know that other packages with knitr
-processed .Rmd vignettes are accessible from the package, but can't figure out why mine are not.
What is missing?
我的vignettes/
目录仅包含.Rmd文件(不包含PDF),但与例如
My vignettes/
directory contains only the .Rmd files (no PDFs), but that seems the same as, e.g., https://github.com/yihui/knitr/tree/master/vignettes.
推荐答案
请注意,当您devtools::install()
时,默认情况下 devtools 不会构建小插图(某些install_*
函数(如install_github()
)目录中的软件包.安装软件包时,必须指定参数build_vignettes = TRUE
.当前,如果仅使用RStudio按钮Build & Reload
,则无法使用 devtools 构建小插曲.您必须Build Source Package
,然后在tarball上运行R CMD INSTALL
.或在R控制台中运行devtools::install(build_vignettes = TRUE)
.
Note devtools does not build vignettes by default when you devtools::install()
(same thing for some install_*
functions like install_github()
) a package from a directory. You have to specify the argument build_vignettes = TRUE
when you install the package. Currently there is no way to build vignettes using devtools if you just use the RStudio button Build & Reload
. You have to Build Source Package
, and run R CMD INSTALL
on the tarball. Or run devtools::install(build_vignettes = TRUE)
in the R console.
这篇关于knitr .Rmd渐晕不与vignette()一起出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!