Run a tutorial provided by an installed R package.
Usage
run_tutorial(
name = NULL,
package = NULL,
...,
shiny_args = NULL,
clean = FALSE,
as_rstudio_job = NULL
)
Arguments
- name
Tutorial name (subdirectory within
tutorials/
directory of installedpackage
). Alternatively, ifpackage
is not provided,name
may be a path to a local tutorial R Markdown file or a local directory containing a learnr tutorial. Ifpackage
is provided,name
must be the tutorial name.- package
Name of package. If
name
is a path to the local directory containing a learnr tutorial, thenpackage
should not be provided.- ...
Unused. Included for future expansion and to ensure named arguments are used.
- shiny_args
Additional arguments to forward to
shiny::runApp
.- clean
When
TRUE
, the shiny prerendered HTML files are removed and the tutorial is re-rendered prior to starting the tutorial.- as_rstudio_job
Runs the tutorial in the background as an RStudio job. This is the default behavior when
run_tutorial()
detects that RStudio is available and can run jobs. Set toFALSE
to disable and to run the tutorial in the current R session.When running as an RStudio job,
run_tutorial()
sets or overrides thelaunch.browser
option forshiny_args
. You can instead use theshiny.launch.browser
global option in your current R session to set the default behavior when the tutorial is run. See the shiny options documentation for more information.
Examples
# display all "learnr" tutorials
available_tutorials("learnr")
#> Available tutorials:
#> * learnr
#> - ex-data-basics : "Data basics"
#> - ex-data-filter : "Filter observations"
#> - ex-data-mutate : "Create new variables"
#> - ex-data-summarise : "Summarise Tables"
#> - ex-setup-r : "Set Up"
#> - hello : "Hello, Tutorial!"
#> - polyglot : "Multi-language exercises"
#> - quiz_question : "Tutorial Quiz Questions in `learnr`"
#> - setup-chunks : "Chained setup chunks"
#> - slidy : "Slidy demo"
#> - sql-exercise : "Interactive SQL Exercises"
# run basic example within learnr
if (FALSE) {
run_tutorial("hello", "learnr")
}