class: center, middle, inverse, title-slide # Self-Assessment with
learnr
## useR Boston Meetup ### Maria Kamenetsky ### University of Wisconsin-Madison ### February 24, 2021 --- #Overview - Background & Motivation - `learnr` Basics - Sharing Your Tutorial - Demo - Wrap-Up --- # Background .center[![description of the image](rstudioconf.png)] rstudio::global(2021) Diversity Scholarship - Mine Çetinkaya-Rundel workshop: **“What they forgot to teach you about teaching R”** - Alison Hill: “Introducing Yourself Online” --- # The package: `learnr` The **learnr** package can be used to turn *R Markdown* documents into interactive tutorials. Can easily incorporate figures, equations, videos, interactive *Shiny* components. For more information see https://rstudio.github.io/learnr/ -- **Goal**: Use `learnr` for student *self-assessment* --- # Motivation STAT679-III: Spatial Statistics for Lattice Data Co-developed with Dr. Jun Zhu Focus on lattice data, exploratory spatial data analysis (`tidyverse`), Moran's I & Geary's C (`spdep`), simultaneous autoregressive (SAR) and conditional autoregressive models (CAR) (`spatialreg`) Cognitive overhead for learners to learn new material *and* review previous statistics materials and `R`. --- # The Audience Professional MS in [Environmental Observation & Informatics](https://nelson.wisc.edu/graduate/professional-programs/environmental-observation-informatics/index.php) - Diverse background (engineering, ecology, GIS, ...) Course sequence: - Summer: - Statistics: Foundations and Regression With Big Data - Spring Semester: - **5 week course on Spatial Statistics for Lattice Data ** --- # Self-Assessment Tool https://github.com/mkamenet3/stat679selfassessment .center[![description of the image](satool.png)] --- # `learnr` Basics After installing the `learnr` package: - `File` -> `New File` -> `R Markdown` -> (From Template) Interactive Tutorial ``` --- title: "STAT679-III: Self-Assessment" output: learnr::tutorial runtime: shiny_prerendered --- ``` --- # `learnr` Basics ````markdown ```{r setup} data("mtcars") mod <- lm(mpg ~ wt, data=mtcars) par(mfrow=c(1,2)) plot(mod, which=c(1,2)) ``` ```` ````markdown *```{r myquiz} library(learnr) quiz( question("In the above diagnostic plots, the plot on the *left* is:", answer("Residuals vs. fitted plot", correct=TRUE), answer("QQ plot"), answer("I'm not sure"), allow_retry = TRUE, try_again_button = "Try again", correct="Correct!") ) ``` ```` --- # `learnr` Basics ````markdown ```{r setup} data("mtcars") mod <- lm(mpg ~ wt, data=mtcars) par(mfrow=c(1,2)) plot(mod, which=c(1,2)) ``` ```` ````markdown ```{r myquiz} *library(learnr) quiz( question("In the above diagnostic plots, the plot on the *left* is:", answer("Residuals vs. fitted plot", correct=TRUE), answer("QQ plot"), answer("I'm not sure"), allow_retry = TRUE, try_again_button = "Try again", correct="Correct!") ) ``` ```` --- # `learnr` Basics ````markdown ```{r setup} data("mtcars") mod <- lm(mpg ~ wt, data=mtcars) par(mfrow=c(1,2)) plot(mod, which=c(1,2)) ``` ```` ````markdown ```{r myquiz} library(learnr) *quiz( question("In the above diagnostic plots, the plot on the *left* is:", answer("Residuals vs. fitted plot", correct=TRUE), answer("QQ plot"), answer("I'm not sure"), allow_retry = TRUE, try_again_button = "Try again", correct="Correct!") ) ``` ```` --- # `learnr` Basics ````markdown ```{r setup} data("mtcars") mod <- lm(mpg ~ wt, data=mtcars) par(mfrow=c(1,2)) plot(mod, which=c(1,2)) ``` ```` ````markdown ```{r myquiz} library(learnr) quiz( * question("In the above diagnostic plots, * the plot on the *left* is:", answer("Residuals vs. fitted plot", correct=TRUE), answer("QQ plot"), answer("I'm not sure"), allow_retry = TRUE, try_again_button = "Try again", correct="Correct!") ) ``` ```` --- # `learnr` Basics ````markdown ```{r setup} data("mtcars") mod <- lm(mpg ~ wt, data=mtcars) par(mfrow=c(1,2)) plot(mod, which=c(1,2)) ``` ```` ````markdown ```{r myquiz} library(learnr) quiz( question("In the above diagnostic plots, the plot on the *left* is:", * answer("Residuals vs. fitted plot", correct=TRUE), * answer("QQ plot"), * answer("I'm not sure"), allow_retry = TRUE, try_again_button = "Try again", correct="Correct!") ) ``` ```` --- # `learnr` Basics ````markdown ```{r setup} data("mtcars") mod <- lm(mpg ~ wt, data=mtcars) par(mfrow=c(1,2)) plot(mod, which=c(1,2)) ``` ```` ````markdown ```{r myquiz} library(learnr) quiz( question("In the above diagnostic plots, the plot on the *left* is:", answer("Residuals vs. fitted plot", correct=TRUE), answer("QQ plot"), answer("I'm not sure"), * allow_retry = TRUE, * try_again_button = "Try again", * correct="Correct!") ) ``` ```` --- # Sharing Your Tutorial: (1) GitHub Share your `learnr` tutorial as a package: ``` *#install from GitHub *install.packages("remotes") *remotes::install_github("mkamenet3/stat679selfassessment") #Run tutorial locally library(stat679selfassessment) learnr::run_tutorial("selfassessment", package = "stat679selfassessment") ``` GitHub: https://github.com/mkamenet3/stat679selfassessment --- # Sharing Your Tutorial: (1) GitHub Share your `learnr` tutorial as a package: ``` #install from GitHub install.packages("remotes") remotes::install_github("mkamenet3/stat679selfassessment") *#Run tutorial locally *library(stat679selfassessment) *learnr::run_tutorial("selfassessment", package = "stat679selfassessment") ``` GitHub: https://github.com/mkamenet3/stat679selfassessment --- # Sharing Your Tutorial: (2) Use mybinder.org Create 3 additional files in your directory: -- 1) `install.R` Define the packages to be installed: ``` *install.packages("learnr") *install.packages("MASS") *install.packages("knitr") ``` -- 2) `runtime.txt` Define the `R` version to use in the Docker image and the date: ``` *r-3.6-2021-02-12 ``` -- 3) `postBuild` Move the tutorial R Markdown file to the working directory so it launches from mybinder.org: ``` *mv inst/tutorials/selfassessment/ . ``` --- # Demo --- # Acknowledgements - RStudio - Mine Çetinkaya-Rundel - `learnr` [developers](https://cran.r-project.org/web/packages/learnr/index.html) (Barret Schloerke, JJ Allaire, Barbara Borges, Angela Li, RStudio, Ajax.org B.V., Zeno Rocha, Nick Payne, Jake Archibald) - Ted Laderas, [*Getting LearnR tutorials to run on mybinder.org*](http://laderast.github.io/2020/09/15/getting-learnr-tutorials-to-run-on-mybinder-org/) --- class: center, middle # Thank you! @mkamenets https://mariakamenetsky.com/