-
Notifications
You must be signed in to change notification settings - Fork 3
/
README.qmd
109 lines (77 loc) Β· 4.75 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
---
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)
})
```
# Data Visualization with R <a href='https://datavizs24.classes.andrewheiss.com/'><img src='files/favicon-512.png' align="right" height="139" /></a>
[PMAP 8551/4551 β’ Summer 2024](https://datavizs24.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/) = 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 `datavizs24.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:
- **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(readr::read_file(workflow_graph))
cat("\n```")
```
## Fonts and colors
The fonts used throughout the site are [Fira Sans Condensed](https://fonts.google.com/specimen/Fira+Sans+Condensed) and [Barlow](https://fonts.google.com/specimen/Barlow).
The colors for the site and hex logo come from the [plasma](https://cran.r-project.org/web/packages/viridis/vignettes/intro-to-viridis.html#the-color-scales) color scale from the viridis color maps:
```r
viridisLite::viridis(8, option = "plasma", begin = 0.1, end = 0.9)
```
```{r show-plasma, fig.width=8, fig.height=1, echo=FALSE, warning=FALSE, message=FALSE}
library(tidyverse)
pal_plasma <- viridisLite::viridis(8, option = "plasma", begin = 0.1, end = 0.9) %>%
# Remove the trailing transparency "FF" from the hex codes
str_sub(end = -3)
tibble(
x = 1:length(pal_plasma),
color = pal_plasma
) %>%
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).