[1] 4
Dynamic documents and rendering websites
March 31, 2024
Where does the name come from?
Allows you to write documents with both
And then render these documents into different formats:
If you are familar with R, you have likely heard of the Rmarkdown
package.
Rmarkdown allows writing R code + markdown in the same file, and compiling documents.
Quarto is the successor to Rmarkdown.
Each Quarto Document has two sections:
YAML (yet another markup language) controls the settings.
Here is a basic YAML that sets the
YAMLs are always declared at the top of the document, between two sets of —
Quarto uses markdown for text content.
If we want to include code in our document, we use a code cell:
The triple backticks ``` are used to demark a code chunk.
The {r} tells Quarto this is an R code cell.
For now, we will just use Quarto to combine markdown + R code
But you can instead use Quarto with
You can only use one coding engine in a single document—no mixing languages.
Python:
Julia:
Python and Julia both are executed using Jupyter.
Next lectures we will be talking about Python and Julia, and once we have those languages installed, we can use them with Quarto.
Code cells have a variety of settings,
Code cells have a variety of settings, for instance,
Code cells have a variety of settings, for instance,
Code cells have a variety of settings, for instance,
Instead, you can set the code cell settings for all cells in the YAML.
All of your code cells run in order, in the same R session.
This means you can use variables and packages from prior code cells.
Code cells can output figures.
Use fig-cap
to set a caption (title).
Use fig-width
and fig-height
to control the figure size.
You can write inline math between two dollar signs: $ $
Rendering \sum_{i=0}^{\infty}x^i as math \(\sum_{i=0}^{\infty}x^i\) that is inline.
Instead, you can use “display math” with $$ $$ to make an aligned block of math.
$$
\sum_{i=0}^{\infty}x^i
\\
\max_{a} \int_0^1 U(a)
$$
\[ \sum_{i=0}^{\infty}x^i \\ \max_{a} \int_0^1 U(a) \]
Quarto will
There are a couple of options for making presentation slides:
format: beamer
format: revealjs
Individual slides are created with a level-2 header.
Some text on my slide
Some more text.
We have already seen that Quarto files can be rendered as HTML documents.
In order to create an actual website, we need to add one more file to our repository:
Is a YAML file of settings.
Declares this a Quarto Project.
For a website,
A Basic Quarto Document
A Quarto presentation
Take a look at the Quarto Academic Website template
Look at Quarto documentation