Design an R package vignette
This document is the vignette skeleton dist_conversion.Rmd
created in the last exercise. It includes the most familiar parts of an R Markdown document:
- A YAML header that contains some metadata
- Narrative text written in Markdown
- R code chunks surrounded by
```{r}
and```
; a syntax that comes from theknitr
package
To develop package documentation for the unitConverter
package, it is vital to show users many different ways to work with the functionality of the package. Vignettes serve that purpose in both showing examples and also adding explanatory text and clarifications in an easy-to-read format.
This exercise is part of the course
Developing R Packages
Exercise instructions
- Create a heading on line 22 of "Convert feet to meters" with no subheadings.
- Add "We can use the package to convert 5 feet into meters as follows." after the the heading, leading one line of space.
- In the dist-example chunk, make the appropriate call to the
dist_converter()
function to achieve the task you have described. - At the end, output the result inline with "Five feet is
r dist_result
meters."
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
{"dist_conversion.Rmd":"___\ntitle: \"Distance Conversion Examples\"\noutput: rmarkdown::html_vignette\nvignette: >\n %\\VignetteIndexEntry{Distance Conversion Examples}\n %\\VignetteEngine{knitr::rmarkdown}\n %\\VignetteEncoding{UTF-8}\n___\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n collapse = TRUE,\n comment = \"#>\"\n)\n```\n\n```{r setup}\nlibrary(unitConverter)\n```\n\n\n\n\n\n```{r dist-example}\ndist_result <- \n```\n\n\n"}