Getting started with R package vignettes

Developing R Packages

Jasmin Ludolf

Content Developer

R package structure

Example package structure

Developing R Packages

Purpose of vignettes in R Package documentation

  • Provide detailed explanations
  • Highlight practical examples
  • Give comprehensive tutorials

Ah-ha light bulb moment with documentation

Developing R Packages

Vignette best practices

  • Clear and focused content
  • Well-organized structure
    • Clear headings and subheadings
    • Text summarizing R code to come
    • Straightforward R code
    • Text discussing R code results
  • Engaging examples and use cases

Documentation image

Developing R Packages

Browsing an R Package Vignette

  • Find best practice examples in other package vignettes
browseVignettes("dplyr")

dplyr vignettes page

Developing R Packages

Browsing an R Package Vignette

  • Find best practice examples in other package vignettes
browseVignettes("dplyr")

dplyr vignettes page

Developing R Packages

HTML version of a vignette

dplyr HTML vignette

Developing R Packages

source version of a vignette

source link selection

Developing R Packages

source version of a vignette

source code of vignette

Developing R Packages

source version of a vignette YAML header

 

zoom in on source code header

Developing R Packages

Vignette metadata

Cat photo metadata analogy

  • Title (title:) - summarizes vignette content
  • Output (output:) - type of output, rmarkdown::html_vignette usually chosen
  • Description (description: >) - overview of content
  • Vignette: (vignette: >) - additional metadata, uses %\ to start entries
Developing R Packages

Vignettes versus articles

Vignette:

  • Focuses on package-specific functionality
  • Provides hands-on examples
  • Typically included in the package documentation

Article:

  • Covers broader topics or research
  • Presents findings or insights
  • Published separately from the package
Developing R Packages

Let's practice!

Developing R Packages

Preparing Video For Download...