开始使用免费开始使用

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 the knitr 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.

本练习是课程的一部分

Developing R Packages

查看课程

练习说明

  • 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."

交互式实操练习

通过完成这段示例代码来试试这个练习。

{"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"}
编辑并运行代码