Basics of writing with Quarto
2024-07-12
Recording your data analysis story (= the choices you make) is important ⚠️
A story is not easy to extract from code:
Telling a story is not the main purpose of coding languages (it’s telling a computer what to do)
Not everybody can read code
Solution: tell your story together with your code!
Literate programming combines programming with documentation language
Coined by Donald E. Knuth in 1984 (!)
Code follows the documentation (and not the other way around)
Some examples:
JupyterLab / notebook
Google colab
Rmarkdown
Quarto
Text is typically written in markdown
Code is in (executable) code chunks
Project: a collection of code, notebooks, environments and data that serve the same analysis aim
Work in projects to:
Define goals and tasks
Organize yourself
Keep a good documentation
Communicate about methods, goals, results etc.
Word of advice: keep projects small!
Documents: html, pdf and MS word
Presentations: Revealjs (html), Powerpoint (pptx) and Beamer (pdf/latex)
Websites
Books
Platforms:
VSCode: most used code editor. Works well for rendering python documents.
Rstudio: code editor for R. Works well for rendering R documents.
Setup:
Start with a template (Document, Presentation, Website or Book)
Start coding!
_quarto.yml
: YML file with project-wide settings.git
: Everything required for version control with gitmy_awesome_project.Rproj
: R-project based settingsmy_awesome_project.qmd
: Where the work is done!qmd
file---
title: "My awesome project"
author: "Jan Janssen"
date: 2023-06-20
format:
html:
theme: cosmo
toc: true
---
Markdown text
Code blocks
Contents of my_new_analysis.qmd
:
After rendering:
Markdown Syntax | Output |
---|---|
|
italics, bold, bold italics |
|
superscript2 / subscript2 |
|
|
|
verbatim code |
Markdown syntax | Output |
---|---|
|
Header 1 |
|
Header 2 |
|
Header 3 |
|
Header 4 |
GO fair website
![logo of SIB](logo.svg){#fig-logo width="300" fig-align="left"}
As you can see from @fig-logo, it is red.
As you can see from Figure 1, it is red.
```{r}
#| label: "fig-mpg-vs-drat"
#| fig-cap: "mpg versus drat"
#| fig-align: "left"
library(ggplot2)
mtcars |>
ggplot(aes(x = drat, y = mpg)) + geom_point() + theme_bw()
```
From @fig-mpg-vs-drat you can see there is a positive correlation.
From Figure 2 you can see there is a positive correlation.
For example:
Visual editor - have a particular look at Insert Anything
Complete overview at https://quarto.org/docs/guide/
More extensive ‘getting started’ tutorial at https://quarto.org/docs/get-started/
Use Rstudio to:
Initiate a Quarto website project
Create a website of two pages with:
Render locally