5  Some advanced things

Author
Affiliation

Dr. Devan Becker

Wilfrid Laurier University

Published

June 7, 2024

5.1 webR

Instructions from this presentation.

Install the webR Quarto extension:

quarto add coatless/quarto-webr

Add the webR filter to the yaml:

format: revealjs
filters:
  - webr

Add a webR code block:

```{webr-r}
# set a random seed and generate data
set.seed(123)
x <- rnorm(100)

# calculate mean
mean(x)
```

5.2 ShinyLive

Shiny Live allows either R or Python shiny apps to be run from within the book - without storing the book on a shiny server! See here for a tutorial.

Every time the user opens your book, the shiny app installs all of the required packages. For best results, keep packages to a minimum.

(This repo does not have an example because the extension adds dependencies. I’ll maybe make another repo just to outline the steps I needed to take.)

5.3 Quizzes for your LMS

In my slides, I include something like:

## Q1

Which of the following statements is *False*?

a. True
b. False

<!--- B --->

A custom R script extracts the “B” from the comment string, then formats an MC question according to my LMS.

The question is shown only on the slides, students answer on the LMS.

This is specific to the way I do things, but it has saved quite a bit of time and lets me do quizzes tied to their student numbers without an external tool.

5.4 Partially Populated Slides with Full Notes

Sys.getenv("QUARTO_PROFILE")
[1] "book"

Using the profile in R:

blank <- function(x) {
    if(Sys.getenv("QUARTO_PROFILE") == "book") {
        return(x)
    } else {
        return("________")
    }
}

Forgetful Sally was so forgetful that when she tried to remember something she drew a blank.

5.5 Solutions (html only)

How can I get an arbitrary block of text to be hidden until the user asks for it?

Solution
<details>
<summary>**Solution**</summary>

</details>

5.6 Include from a private repo

You can have a separate repo that is private (e.g., if it has quizzes with solutions), then include files from that repo.

  • An “include” is a file that is copied verbatim when rendering.