-
Notifications
You must be signed in to change notification settings - Fork 0
/
06a_quarto-intro.qmd
313 lines (211 loc) · 8.3 KB
/
06a_quarto-intro.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
---
title: "Introduction to Quarto"
subtitle: "Next generation scientific publishing in R"
---
Quarto is a **modern, open-source, and flexible platform for creating documents, reports, presentations, and more, primarily focused on data science and technical writing**.
Quarto is built on top of R Markdown and Pandoc, and is designed to be easy to use, highly customizable, and to produce high-quality output.
::: callout-important
*Quarto is a standalone tool but does ship with later versions of Rstudio. Upgrades do need to be downloaded and installed manually however. See Quarto [Download](https://quarto.org/docs/download/) page for latest release.*
:::
Quarto has an **active community of users and contributors who provide support, share tips and tricks, and contribute to the development of the platform**. This community aspect fosters learning and collaboration among users.
Quarto is **closely related to literate programming in its philosophy and functionality. **
## Literate programming
Literate programming is a programming paradigm first introduced by **Donald E. Knuth**.
> **Treat program as literature meant to be understandable to human beings**
>
> - move away from writing programs in the manner and order imposed by the computer
> - **focus instead on the logic and flow of human thought and understanding**
> - single document to integrate data analysis (executable code) with textual documentation, **linking data, code, and text**
### Why is this important in science:
#### **Enables reproducibility**
Enables reproducibility through packaging code, text and output into a single executable document.
#### **Enables open science**
Literate programming allows us to record and publish information and discussions about code and analyses in more readable formats.
## **Literate programming in R**
### Quarto (`qmd`) Overview
**Quarto integrates:**
– a **documentation** language (`.md`)
– a number of **programming** languages (including `R`)
Allows us to combine **tools, processes** and **outputs** into interactive, reproducible **evidence streams** that are easily shareable, particularly through the web.
#### A researchers perspective on Quarto
A reproducible workflow in action:
```{r}
#| echo: false
knitr::include_app("https://www.youtube.com/embed/s3JldKoA0zw")
```
## Elements of Quarto
### **markdown {`.md`}**
Simplified version of the **`html`** markup language. User can focus on communicating & disseminating
- intended to be as **easy-to-read** and **easy-to-write** as possible.
- most powerful as a **format for writing to the web.**
- **syntax is very small**, corresponding only to a very small subset of HTML tags.
- clean and legible **across platforms (even mobile) and outputs.**
- **formatting handled automatically**
- html **markup language also handled**.
### **code {r,** python, SQL, ... **}**
- **Code chunks defined through special notation. Executed in sequence**. Exceution of individual chunks controllable
- **Analysis self-contained and reproducible**
- Run in a fresh R session every time document is knit.
- A number of [Language Engines](https://rmarkdown.rstudio.com/authoring_knitr_engines.html) are supported by `knitr`
- **R** (default)
- Python
- SQL
- Bash
- Julia
- Observable
## Quarto **Outputs**
Quarto can output to a variety of formats, including:
- HTML
- PDF
- Word
Which can be combined into a variety of more complex formats, including:
- Slides
- Books
- Dashboards
- Websites
- Manuscripts
```{r, out.width="60%", echo=FALSE}
knitr::include_graphics("assets/RMarkdownOutputFormats.png")
```
**Superpower: Simple interface to powerful modern web technologies and libraries**
## Quarto extensions
Quarto has a [number of extensions](https://quarto.org/docs/extensions/), many community contributed, that make it even more powerful:
Examples of Quarto extensions include:
\- **fontawesome**: Use Font Awesome icons in HTML and PDF documents.
\- **academicons**: Use Academicons in HTML documents.
\- **line-highlight**: Filter to enable source code and output line highlighting for HTML documents.
And much more!
All this makes it incredibly versatile.
## Publish to the web for free!
### **Quarto Pub**:
[Quarto Pub](https://quartopub.com/) is a free publishing service for content created with Quarto. Quarto Pub is ideal for blogs, course or project websites, books, presentations, and personal hobby sites.
[![](assets/quarto_pub.png)](https://quartopub.com/)
Quarto Pub allows you to publish rendered quarto documents and websites to the web for free with a simple command.
```{bash}
#| eval: false
#| filename: "Terminal"
quarto publish quarto-pub
```
Learn more: <https://quarto.org/docs/publishing/quarto-pub.html>
## Applications of Quarto in research
`qmd` documents can be useful for a number of research related materials
- [**Vignettes**](http://r-pkgs.had.co.nz/vignettes.html): long form documentation.
- Analyses
- Documentation (code & data)
- Supplementary materials
- Reports
- Papers
- Personal research websites and blogs
- Theses!
## Quarto Features for Scientific Publishing
::: panel-tabset
### Citations & Footnotes
![](assets/citations-quarto.png)
[See more](https://quarto.org/docs/authoring/footnotes-and-citations.html)
Quarto can generate citations and a bibliography in a number of styles. You will need:
- A bibliographic data source, (.bib) or (.bibtex) file.
- Optionally, a CSL file which specifies the formatting to use when generating the citations and bibliography.
### Front matter
::: grid
::: g-col-8
``` yaml
---
title: "Toward a Unified Theory of High-Energy Metaphysics: Silly String Theory"
date: 2008-02-29
author:
- name: Josiah Carberry
id: jc
orcid: 0000-0002-1825-0097
email: [email protected]
affiliation:
- name: Brown University
city: Providence
state: RI
url: www.brown.edu
abstract: >
The characteristic theme of the works of Stone is
the bridge between culture and society. ...
keywords:
- Metaphysics
- String Theory
license: "CC BY"
copyright:
holder: Josiah Carberry
year: 2008
citation:
container-title: Journal of Psychoceramics
volume: 1
issue: 1
doi: 10.5555/12345678
funding: "The author received no specific funding for this work."
---
```
[See more](https://quarto.org/docs/authoring/front-matter.html)
:::
::: g-col-4
![](assets/frontmatter-quarto.png)
:::
:::
Scholarly articles require much more detail in their front matter & Quarto provides a rich set of YAML metadata keys to describe these details:
- authors and their affiliations,
- abstracts and keywords.
- information on copyright, licensing and funding.
### Cross-references
::: grid
::: g-col-6
Adding a reference to an image:
``` md
![Elephant](elephant.png){#fig-elephant}
```
Referencing the image:
``` md
See @fig-elephant for an illustration.
```
[See more](https://quarto.org/docs/authoring/cross-references.html)
:::
::: g-col-6
![](assets/crossref-quarto.png)
:::
:::
Cross-references make it easier for readers to navigate your document by providing numbered references and hyperlinks to various entities like figures and tables
### more...
- [Equations](https://quarto.org/docs/authoring/markdown-basics.html#equations)
- [Diagrams](https://quarto.org/docs/authoring/markdown-basics.html#diagrams)
- [Tables](https://quarto.org/docs/authoring/tables.html)
- [Figures](https://quarto.org/docs/authoring/figures.html)
:::
## Resources
### Quarto cheatsheet
```{r}
#| echo: false
knitr::include_url("assets/cheatsheets/quarto.pdf")
```
### Quarto Guide
Comprehensive guide to using Quarto.
```{r}
#| echo: false
knitr::include_url("https://quarto.org/docs/guide/")
```
### Quarto Reference
Options reference for formats, code cells, and projects.
```{r}
#| echo: false
knitr::include_url("https://quarto.org/docs/reference/")
```
### Quarto Tutorials
Tutorial to get started with Quarto.
```{r}
#| echo: false
knitr::include_url("https://quarto.org/docs/get-started/")
```
### Quarto Gallery
Check out the [Quarto gallery](https://rmarkdown.rstudio.com/gallery.html) for ideas.
```{r}
#| echo: false
knitr::include_url("https://quarto.org/docs/gallery/")
```
### Quarto Extensions
```{r}
#| echo: false
knitr::include_url("https://quarto.org/docs/extensions/")
```