Learn R Programming

s20x (version 3.2.1)

casestudy: Render a case study to HTML

Description

Renders a specified case study R Markdown file shipped with the package to HTML and optionally opens it in a web browser.

Usage

casestudy(
  id,
  output_dir = tempfile("s20x_case_study_"),
  open = interactive(),
  quiet = TRUE,
  ...
)

cs(...)

Value

Invisibly returns the path to the rendered HTML file.

Arguments

id

A case study identifier. Flexible formats are accepted, including "CS9_2", "CS9.2", "9_2", or "9.2".

output_dir

Directory where the rendered HTML file should be written. Defaults to a temporary directory.

open

Logical; if TRUE (default), open the rendered HTML file in the default web browser.

quiet

Logical; passed to rmarkdown::render() to suppress output.

...

Additional arguments passed to rmarkdown::render().

Details

Case studies are expected to live in inst/case_studies and to be named using the pattern CS<chapter>_<number>.Rmd (for example, CS9_2.Rmd).

The case study is rendered on demand using rmarkdown::render(). Figures and other outputs are generated at render time; users therefore need any required packages installed for the selected case study.

The rendered HTML file is returned invisibly.

Examples

Run this code
if (FALSE) {
casestudy("CS9_2")
casestudy("9.2")
cs("9_2")
}

Run the code above in your browser using DataLab