-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexploring_quarto.qmd
139 lines (97 loc) · 3.13 KB
/
exploring_quarto.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
---
title: "My Quarto Doc"
author: Sam Csik
date: 2022-04-14
format:
html:
code-fold: true
code-tools: true
code-link: true
execute:
warning: false
message: false
editor_options:
chunk_output_type: console
---
```{r}
#| echo: false
library(tidyverse)
```
## Welcome to my quarto doc!
### What is Quarto?
- quarto is a way of life, a document, a system (lol) that is built for multiple languages (unlike RMarkdown which is a tool developed for R but we've hacked to work with other languages)
- looks VERY similar to RMarkdown (you're already about 90% of the way there)
### Things to try out:
1. open `.qmd` file
2. switch between source & visual editors
3. Render (not knit, from `knitr`)
4. hash pipes `#|` for chunk options
5. no more global options knitr chunk (all goes in yaml)
execute:
warning: false
message: false
6. author, date in yaml has a more "modern feel"
7. `#| label: fig-something`, `#| fig-cap: "something"` (use kebab case)
8. reference figs in-text by their label `@fig-something`
9. add mpg plot + callout to add axis labels
10. add a tip callout
11. add panel-tabset
12. add second fig to first chunk with updated chunk options `fig-subcap:`, `layout-ncol: 2`, and `column: page`
13. add a table using the visual editor "Insert" drop down menu
14. render a plot output in the document margin
::: callout-note
## This plot still needs updated axis labels!
```{r}
#| label: fig-mpg
#| fig-cap: "This is my mpg figure"
#| fig-subcap:
#| - "Color by number of cylinders"
#| - "Color by engine displacement, in liters"
#| fig-alt: "Here is my very descriptive alt text for this first figure"
#| layout-ncol: 2
#| column: page
ggplot(mpg, aes(x = hwy, y = cty, color = cyl)) +
geom_point(alpha = 0.5) +
scale_color_viridis_c() +
theme_minimal()
ggplot(mpg, aes(x = hwy, y = cty, color = displ)) +
geom_point(alpha = 0.5) +
scale_color_viridis_c() +
theme_minimal()
```
:::
@fig-mpg is my first ever cross-referenced quarto figure and I'm very excited about it. @fig-mpg-1 is colored by number of cylinders and @fig-mpg-2 is colored by engine displacement.
::: callout-tip
Reminder! In Visual editor mode, you can add callouts under the Insert drop down menu.
:::
## Surprise! Tabsets!
::: panel-tabset
## my first tab
hello, it's me
## my second tab
surprise, there's more content here! You can also add a code chunk to include figure/table outputs
```{r}
ggplot(mpg, aes(x = hwy, y = cty, color = displ)) +
geom_point(alpha = 0.5) +
scale_color_viridis_c() +
theme_minimal()
```
:::
::: callout-tip
Use the Visual editor to easily add and edit tables!
:::
| Col1 | Col2 | Col3 |
|------|-------|------|
| 100 | hello | \- |
| 200 | it's | \- |
| 300 | me | \- |
You can now also render plot/table outputs in the margin of your quarto doc using the `column: margin` chunk option!!! Check out some of the other code chunk options (below) for adding a table label, caption, and caption location:
```{r}
#| column: margin
#| label: tbl-mtcars
#| tbl-cap: first three columns and rows of the mtcars dataset
#| tbl-cap-location: top
knitr::kable(
mtcars[1:3, 1:3]
)
```