How to build a pdf vignette in R and RStudio

孤者浪人 提交于 2019-12-21 04:04:51

问题


I am new to writing R packages. I'm trying to learn how to make a vignette for my package. I have created a vignettes folder with a file "getting-started.Rmd"

---
title: "WaterML Tutorial"
author: "Jiri Kadlec"
date: "`r Sys.Date()`"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Introduction to the WaterML R package}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

## Quick Start

This simple example shows how to get started with the <my R package>.

To build the vignette I use the command:

devtools::build_vignettes()

Then I run Rcmd.exe INSTALL my_package, and to view my vignette I run:

browseVignettes("my_package")

However I only see the vignettes in the html and source format:

As you see in the screenshot, there's no "pdf" option. How do I configure my .Rmd file to create my vignette in the pdf format?


回答1:


In your header, you are telling R to output only an html vignette in line:

output: rmarkdown::html_vignette

If you want pdf, try:

output: pdf_document

According to R packages:

Output: this tells rmarkdown which output formatter to use. There are many options that are useful for regular reports (including html, pdf, slideshows, …) but rmarkdown::html_vignette has been specifically designed to work well inside packages. See ?rmarkdown::html_vignette for more details.

So you might have a few small problems using a raw pdf.

At this time, rmarkdown does not have a output: rmarkdown::pdf_vignette option



来源:https://stackoverflow.com/questions/31037907/how-to-build-a-pdf-vignette-in-r-and-rstudio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!