18

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: I don't see the pdf option for vignettes

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?

Siddd
  • 274
  • 1
  • 3
  • 13
jirikadlec2
  • 1,256
  • 1
  • 23
  • 36
  • Does this answer your question? http://stackoverflow.com/questions/30936969/enforce-pdf-package-vignette-with-knitr or possibly try [output:pdf_document](http://rmarkdown.rstudio.com/pdf_document_format.html) ? – Ben Bolker Jun 24 '15 at 22:14

1 Answers1

17

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

jeremycg
  • 24,657
  • 5
  • 63
  • 74
  • 9
    And there is no need to have a `output: rmarkdown::pdf_vignette` option (`pdf_document` will simply work). The reason for `html_vignette` is explained here: http://rmarkdown.rstudio.com/package_vignette_format.html – Yihui Xie Jun 25 '15 at 01:15
  • Good explanation. So I see that html_vignette is the preferred format in R packages because the size is much smaller. – jirikadlec2 Jun 26 '15 at 23:06