-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
template-html.qmd
48 lines (39 loc) · 1.28 KB
/
template-html.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
---
title: "Example HTML Page"
subtitle: "Let's rock and roll!"
date: now
author:
- name: FirstName LastName
email: [email protected]
format:
stanford-html: default
---
```{r}
#| label: load-packages
#| echo: false
library(ggplot2)
data(mpg, package = "ggplot2")
```
Consider the `mpg` data set found in the `ggplot2` package. In this data set, there are `{r} nrow(mpg)` observations and `{r} ncol(mpg)` variables.
The plots in @fig-mpg show the relationship between city and highway mileage for 38 popular models of cars.
In @fig-mpg-1 the points are colored by the number of cylinders while in @fig-mpg-2 the points are colored by engine displacement.
```{r}
#| label: fig-mpg
#| fig-cap: "City and highway mileage for 38 popular models of cars."
#| fig-subcap:
#| - "Color by number of cylinders"
#| - "Color by engine displacement, in liters"
#| layout-ncol: 2
#| column: page
#| cache: true
ggplot(mpg, aes(x = hwy, y = cty, color = cyl)) +
geom_point(alpha = 0.5, size = 2) +
scale_color_viridis_c() +
theme_minimal()
ggplot(mpg, aes(x = hwy, y = cty, color = displ)) +
geom_point(alpha = 0.5, size = 2) +
scale_color_viridis_c(option = "E") +
theme_minimal()
```
Example mirrored from:
<https://quarto.org/docs/get-started/computations/rstudio.html#multiple-figures>