learnr2 creates interactive R tutorials that run entirely in the reader's web browser using Quarto and WebR, via the quarto-live extension. It offers learnr-style authoring conveniences --- scaffolding, exercises, hints, solutions, and quizzes --- without Shiny, R Markdown, or a server. A rendered tutorial is a self-contained HTML page.
# install.packages("pak")
pak::pak("PPBDS/learnr2")You will also need the Quarto CLI.
Try the bundled feature-tour tutorial:
library(learnr2)
available_tutorials() # list tutorials bundled with a package
run_tutorial("hello-learnr2") # render + open in your browserScaffold your own tutorial:
create_tutorial("my-tutorial")This creates my-tutorial/my-tutorial.qmd with the quarto-live extension
copied alongside it, so it renders out of the box with Quarto or
quarto::quarto_render().
- Live code cells — editable, runnable R that executes in the browser.
- Exercises — cells with blanks, plus
.hintand.solutionblocks. - Automatic grading — powered by gradethis.
- Quiz questions —
question()/quiz(), graded in the browser with plain JavaScript, including single/multiple choice, free-text, and reflection questions. Answers persist in the browser'slocalStorage.
See the reference index and the bundled hello-learnr2 tutorial for details.