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:



Try the learnr package in your browser

Any scripts or data that you put into this service are public.

learnr documentation built on Sept. 28, 2023, 9:06 a.m.