To create a tutorial, set runtime: shiny_prerendered in the YAML frontmatter of your .Rmd file to turn your R Markdown document into an interactive app.

Then, call library(learnr) within your Rmd file to activate tutorial mode, and use the exercise = TRUE chunk option to turn code chunks into exercises. Users can edit and execute the R code and see the results right within their browser.

For example, here's a very simple tutorial:

source("../../vignettes/articles/snippets.R")
insert_snippet("hello-learnr")

This is what the running tutorial document looks like after the user has entered their answer:



rstudio/learnr documentation built on Sept. 6, 2024, 11:06 p.m.