EDUC 157 β’ Fall 2023
Andreas de Barros β’ School of Education β’
University of California, Irvine
Quarto + {targets} + {renv} + {xaringan} = magic! πͺ
- Install RStudio version 2022.07.1 or later since it has a Quarto installation embedded in it. Otherwise, download and install Quarto separately.
- Open
educ157-23.Rproj
to open an RStudio Project. - If itβs not installed already, R should try to install the {renv}
package when you open the RStudio
Project for the first time. If you donβt see a message about package
installation, install it yourself by running
install.packages("renv")
in the R console. - Run
renv::restore()
in the R console to install all the required packages for this project. - Run
targets::tar_make()
in the R console to build everything. - π All done! π The complete website will be in a folder named
_site/
.
I use the {targets} package to
build this site and all its supporting files. The complete pipeline is
defined in _targets.R
and can be run in the R console
with:
targets::tar_make()
The pipeline does several major tasks:
-
Create supporting data files: The problem sets and examples I use throughout the course use many different datasets that come prepackaged in R packages, I downloaded from sources online, or that I generated myself. To make sure I and my students are using the latest, most correct datasets, the functions in
R/tar_data.R
save and/or generate these datasets prior to building the website. -
Compress project folders: To make it easier to distribute problem sets and in-class activities to students, I compress all the folders in the
/projects/
folder so that students can download and unzip a self-contained RStudio Project as a.zip
file. These targets are dynamically generated so that any new folder that is added to/projects/
will automatically be zipped up when running the pipeline.The pipeline dynamically generates targets for all the
.Rmd
files in/slides/
and renders them using R Markdown rather than Quarto.The pipeline then uses {renderthis} to convert each set of HTML slides into PDFs.
So far, I use LaTeX for my slides, not xaringan, and I create these slides outside the pipeline. I consider transitioning to xaringan soon.
-
Build Quarto website: This project is a Quarto website, which compiles and stitches together all the
.qmd
files in this project based on the settings in_quarto.yml
. See the Quarto website documentation for more details. -
Upload resulting
_site/
folder to my remote server: Quarto places the compiled website in a folder named/_site/
. I push this folder to my a Netlify site, usingquarto publish netlify
in my RStudio Terminal. Then, I have a subdomain on my website, whose settings point to this Netlify site.
This page is largely inspired by Andrew Heissβs site for his class Program Evaluation for Public Service as well as Matt Blackwellβs site for his class Gov 50. If you re-use any of the materials, please respect the licences (see below) and give credit to original authors.
I am grateful for additional help and materials from David Blazar, Fiona Burlig, Arja Dayal, Pierre de Galbert, Alejandro Ganimian, Andrew Ho, Justine Knebelmann, Francisco Lagos, Fernanda Ramirez-Espinoza, and Carly Robinson.
Text and figures: All prose and images are licensed under Creative Commons (CC-BY-NC 4.0)
Code: All code is licensed under the MIT License.