Chapter 8 Package Vignettes
A vignette is a long-form guide to your package. It provides a detailed guide to the package and its functions. Many existing R packages have vignettes. To see the vignette for a specific package, execute: browseVignettes("packagename"):
browseVignettes("dplyr")There can be multiple vignettes, but it could be just one for the whole package. To add vignette to the package, call use_vignette() function with a package name:
usethis::use_vignette("myutils")This will modify the DESCRIPTION file adding knitr package as a suggested dependency and it also created a vignettes/ directory.
To add documentation into myutils.Rmd file we will use RMarkdown:
# Introduction
This is a package with the functions I use most often in my projects.
# Running summaries
To run a summary for a numeric vector, execute:
```{r}
numeric_summary( rnorm (7) )
```
If you want to see a summary of a character vector:
```{r}
char_summary( month.name )
```Once the documentation is written, we can build the vignettes():
devtools::build_vignettes()This creates a subdirectory doc/ that contains the vignette. Click on the html file inside this directory to open it in a browser.