knitr .Rmd 小插图不会出现在 vignette() 中 [英] knitr .Rmd vignettes do not appear with vignette()

查看:16
本文介绍了knitr .Rmd 小插图不会出现在 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),但这似乎与 https://github.com/yihui/knitr/tree/master/vignettes.

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 在你 devtools::install() 时默认不会构建小插图(同样的事情对于一些 install_* 函数,例如 install_github()) 来自目录的包.您必须在安装包时指定参数 build_vignettes = TRUE.如果您只使用 RStudio 按钮 Build &重新加载.您必须 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆