-
Notifications
You must be signed in to change notification settings - Fork 9
/
README.qmd
113 lines (76 loc) Β· 6.49 KB
/
README.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
---
format: gfm
---
<!-- README.md is generated from README.qmd. Please edit that file -->
```{r, include=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.retina = 3
)
withr::with_dir(here::here(), {
targets::tar_load(workflow_graph)
})
```
# Program Evaluation for Public Service <a href='https://evalsp23.classes.andrewheiss.com/'><img src='files/icon-512.png' align="right" height="139" /></a>
[PMAP 8521 β’ Spring 2023](https://evalsp23.classes.andrewheiss.com/)
[Andrew Heiss](https://www.andrewheiss.com/) β’ Andrew Young School of Policy Studies β’ Georgia State University
---
**[Quarto](https://quarto.org/) + [{targets}](https://docs.ropensci.org/targets/) + [{renv}](https://rstudio.github.io/renv/) + [{xaringan}](https://github.com/yihui/xaringan) = magic! `r emoji::emoji("magic")`**
---
## How to build the site
1. Install [RStudio](https://www.rstudio.com/products/rstudio/download/#download) version 2022.07.1 or later since it has a [Quarto](https://quarto.org/) installation embedded in it. Otherwise, download and install [Quarto](https://quarto.org/) separately.
2. Open `evalsp23.Rproj` to open an [RStudio Project](https://r4ds.had.co.nz/workflow-projects.html).
3. If it's not installed already, R *should* try to install the [{renv} package](https://rstudio.github.io/renv/) 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.
4. Run `renv::restore()` in the R console to install all the required packages for this project.
5. Run `targets::tar_make()` in the R console to build everything.
6. `r emoji::emoji("tada")` All done! `r emoji::emoji("tada")` The complete website will be in a folder named `_site/`.
## {targets} pipeline
I use the [{targets} package](https://docs.ropensci.org/targets/) to build this site and all its supporting files. The complete pipeline is defined in [`_targets.R`](_targets.R) and can be run in the R console with:
```{r eval=FALSE}
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`](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/`](/projects/) folder so that students can download and unzip a self-contained RStudio Project as a `.zip` file. These targets are [dynamically generated](https://books.ropensci.org/targets/dynamic.html) so that any new folder that is added to `/projects/` will automatically be zipped up when running the pipeline.
- **Render xaringan slides to HTML and PDF**: Quarto supports HTML-based slideshows through [reveal.js](https://quarto.org/docs/presentations/revealjs/). However, I created all my slides using [{xaringan}](https://github.com/yihui/xaringan), which is based on [remark.js](https://remarkjs.com/) and doesn't work with Quarto. Since (1) I recorded all the class videos using my {xaringan} slides with a fancy template I made, and (2) I don't want to recreate my fancy template in reveal.js yet, I want to keep using {xaringan}.
The pipeline [dynamically generates targets](https://books.ropensci.org/targets/dynamic.html) for all the `.Rmd` files in [`/slides/`](/slides/) and renders them using R Markdown rather than Quarto.
The pipeline then uses [{renderthis}](https://jhelvy.github.io/renderthis/) to convert each set of HTML slides into PDFs.
- **Build Quarto website**: This project is a [Quarto website](https://quarto.org/docs/websites/), which compiles and stitches together all the `.qmd` files in this project based on the settings in [`_quarto.yml`](_quarto.yml). See the [Quarto website documentation](https://quarto.org/docs/websites/) for more details.
- **Upload resulting `_site/` folder to my remote server**: Quarto places the compiled website in a folder named `/_site/`. The pipeline uses `rsync` to upload this folder to my personal remote server. This target will only run if the `UPLOAD_WEBSITES` environment variable is set to `TRUE`, and it will only work if you have an SSH key set up on my personal server, which only I do.
The complete pipeline looks like this:
<small>(This uses [`mermaid.js` syntax](https://mermaid-js.github.io/mermaid/) and should display as a graph on GitHub. You can also view it by pasting the code into <https://mermaid.live>.)</small>
```{r echo=FALSE, results="asis"}
# Make sure there are newlines between the code block boundaries and the output
# from `workflow`, which also needs to be separated by newlines
cat("``` mermaid\n")
cat(workflow_graph, sep = "\n")
cat("\n```")
```
## Fonts and colors
The fonts used throughout the site are [Fira Sans Condensed](https://fonts.google.com/specimen/Fira+Sans+Condensed) (for headings and titles) and [Barlow](https://fonts.google.com/specimen/Barlow) (for everything else).
The colors for the site and hex logo come from a palette of 8 colors generated from the [viridis inferno color map](https://cran.r-project.org/web/packages/viridis/vignettes/intro-to-viridis.html#the-color-scales):
```{r inferno-fake, eval=FALSE}
viridisLite::viridis(8, option = "inferno", begin = 0.1, end = 0.9)
```
```{r show-inferno, fig.width=8, fig.height=1, echo=FALSE, warning=FALSE, message=FALSE}
library(tidyverse)
pal <- viridisLite::viridis(8, option = "inferno", begin = 0.1, end = 0.9)
tibble(x = 1:length(pal),
color = pal) %>%
mutate(x_nice = glue::glue("[{x}]")) %>%
mutate(across(c(color, x_nice), ~fct_inorder(.))) %>%
ggplot(aes(x = color, y = 1, fill = color)) +
geom_tile() +
scale_x_discrete(expand = c(0, 0)) +
scale_fill_identity() +
facet_wrap(vars(x_nice), scales = "free_x", nrow = 1) +
theme_void(base_family = "Inconsolata") +
theme(panel.spacing.x = unit(-1, units = "pt"),
panel.spacing.y = unit(-0.5, units = "lines"),
strip.text = element_blank()) +
theme(axis.text.x = element_text(margin = margin(b = 5)))
```
## Licenses
**Text and figures:** All prose and images are licensed under Creative Commons ([CC-BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/))
**Code:** All code is licensed under the [MIT License](LICENSE.md).