password: quince-blueberry
At the end you’ll have an example of a reproducible html document created with Quarto
Slides are available on GitHub
Tool created by RStudio (Posit)
Create documents that combine code with text
Multiple languages and output formats
Evolution of R Markdown
File extension .qmd
Settings > Extensions
Search “quarto” in extensions search bar
Click the Quarto extension
Click “Install in neds-quarto…”
Settings > Extensions
Search “python”
Click “Python” extension (make sure it is the ms-python one)
Settings > Command Palette
Search “Python: Select interpreter”
Select “Enter interpreter path…” and type “/opt/python/3.11.3/bin/python”
python3 -m pip install jupyter pandas plotly tabulate
File > New File… > Quarto Document (qmd)
Set title and output format
Click Preview (or type Ctrl+Shift+K)
VS Code screenshot
Terminal > New Terminal
Preview your document:
quarto preview my_doc.qmd
quarto render my_doc.qmd
jupyter
option to select the Jupyter kernelNote
YAML: Yet Another Markup Language
File > New File… > Quarto Document (qmd)
Add a YAML declaring a title, author and HTML output
Markdown | Output |
---|---|
**bold** |
bold |
__bold__ |
bold |
*italic* |
italic |
_italic_ |
italic |
~~strikethrough~~ |
|
^superscript^ |
superscript |
~subscript~ |
subscript |
-
, +
or *
)Add the text from task02.txt
to your Quarto doc
Match the formatting (italics, bold, links) of the first sentence in the Adelie Penguin wiki
Add an image of the Adelie Penguin (there’s one in the exercises folder)
Can you add the penguin emoji to your text?
Control properties of the code within the chunk and it’s outputs
Controlled using YAML within the code chunks
Option | Purpose | Default value |
---|---|---|
echo |
Show/hide code chunks in the output | true |
eval |
Whether to evaluate code within the chunk | true |
warning |
Show/hide messages/warnings produced by code in the output | true |
error |
Allow the code to error but show the error in the output | false |
echo
Use to show / hide code
produces:
track | type | shortcut | player | system_played | date | time_period | time | record_duration | |
---|---|---|---|---|---|---|---|---|---|
0 | Luigi Raceway | Three Lap | No | Salam | NTSC | 1997-02-15 | 2M 12.99S | 132.99 | 1 |
1 | Luigi Raceway | Three Lap | No | Booth | NTSC | 1997-02-16 | 2M 9.99S | 129.99 | 0 |
Open the document task03.qmd
Under the analysis subheading, add a code chunk to import Pandas
Hide the code chunk with #| echo: false
Add another code chunk to read in the penguins data (link in doc) and display it i.e.
Make the data loading chunk a collapsed code chunk with #| echo: fenced
and #| code-fold: true
```{python}
#| eval: false
import plotly.express as px
# Filter the data
rainbow_road = mario_kart.loc[
(mario_kart["track"] == "Rainbow Road") &
(mario_kart["type"] == "Three Lap")
].reset_index()
# Plot the data
px.line(
rainbow_road,
x="date",
y="time",
color="shortcut",
title="Progress of Rainbow Road N64 World Records",
line_shape="hv",
markers="."
)
```
ValueError: Mime type rendering requires nbformat>=4.2.0 but it is not installed
| fruit | count | color |
|--------|--------|--------|
| banana | 5 | yellow |
| apple | 6 | red |
| pear | 2 | green |
fruit | count | color |
---|---|---|
banana | 5 | yellow |
apple | 6 | red |
pear | 2 | green |
fruit | count | color |
---|---|---|
banana | 5 | yellow |
apple | 6 | red |
pear | 2 | green |
Open the document task04.qmd
Add a plot showing the distribution of bill length for each sex and species. Use the plotting code below:
fig-cap
code chunk option.