Appendix A — Technical Details

A.1 Quarto

This book was build using Quarto.

A.1.1 Callout blocks

To hide a solution that then can be clicked to view, we use a .callout-tip collapse="true" callout block.

Here are some examples from the Quarto documentation:

Note

Note that there are five types of callouts, including: note, tip, warning, caution, and important.

Warning

Callouts provide a simple way to attract attention, for example, to this warning.

This is Important

Danger, callouts will really improve your writing.

Tip With Title

This is an example of a callout with a title.

This is an example of a ‘collapsed’ caution callout that can be expanded by the user. You can use collapse="true" to collapse it by default or collapse="false" to make a collapsible callout that is expanded by default.

A.1.2 Adding a chapter

To add a new chapter to the book, make a Quarto file containing the chapter text and code. It should have only one top-level header at the beginning which will be the title of the chapter.

Then add it to the list of chapters in the _quarto.yml file.

A.2 Previewing the book

Type quarto preview in the Terminal window.

A.3 Deploying the book to GitHub Pages

Type quarto publish in the Terminal window.

A.4 Deploying the book to Netlify

Type quarto publish netlify in the Terminal window.

A.5 Multiple choice questions

To create multiple choice questions, use functions from the webexercises R package.

The multiple choice question below is created by the inline R code

r longmcq(opts_ci)

What is true about a 95% confidence interval of the mean?

opts_ci <- c(
  answer = "If you repeated the process many times, 95% of intervals calculated in this way contain the true mean",
  "There is a 95% probability that the true mean lies within this range",
  "Approximately 95% of the data fall within this range"
)

A.6 WebR: R in the browser

This Quarto book uses this WebR Quarto extension

https://github.com/coatless/quarto-webr

WebR makes installs a version of R that runs within the browser, and the Quarto extension makes it interactively available in webr-r chunks.

To get this to work, the _quarto.yml had to be modified.

We added a ‘resources’ directive to copy over the java script files, which places them next to the ‘index.html’ file during deployment of the book:

project:
  type: book
  resources: 
    - "webr-serviceworker.js"
    - "webr-worker.js" 

We also enabled the webr filter:

filters:
    - webr

A.7 embedpdf Quarto extension

This book uses the embedpdf Quarto extension from https://github.com/jmgirard/embedpdf, which was installed via this command:

quarto add jmgirard/embedpdf

To embed a PDF, use code like this:

{{< pdf dummy.pdf width=100% height=800 >}}

However, the PDF embedding done this way did not work in Chrome.

Example:

Unable to display PDF file. Download instead.

So instead we used an iframe, which works on Chrome, Firefox, and Safari:

 <iframe width="100%" height="800" src="pdfs/GitHubIntro.pdf">

Note that for iframe embedding of Panopto video from the University of Pittsburgh, one needs to use a credentialless iframe.