08 - Advanced
Quarto +knitr
You may have a set of parameters that are used to create different variations of a report. For example:
knitr
parametersParameters are accessed as params$NAME
in the document.
Or in inline code r params$NAME
```{r}
#| label: setup
#| include: false
library(tidyverse)
library(palmerpenguins)
smaller <- penguins |>
filter(species == params$species,
!is.na(body_mass_g))
```
We have data about `r nrow(penguins)` penguins.
The distribution of the
`r params$species` penguins are shown below:
```{r}
#| echo: false
smaller |>
ggplot(aes(body_mass_g)) +
geom_histogram(binwidth = 100)
```
Directory matters!
materials/workshop/08-knitr/penguin-params.qmd
materials/workshop/08-knitr/render-params.R
render-params.R
This page has commenting with Hypothes.is enabled via the following YAML option:
comments:
hypothesis: true
Quarto Extensions are a powerful way to modify or extend the behavior of Quarto, and can be created and distributed by anyone. There are two types of extensions available:
Shortcodes are special markdown directives that generate various types of content. For example, you could create shortcodes to embed tweets or videos in a document.
Filters are a flexible and powerful tool for introducing new global behaviors and/or new markdown rendering behaviors. For example, you could create filters to implement output folding, an image carousel, or just about anything you can imagine!
Note that you have to use at least version Quarto v1.0.15
to use extensions
Available extensions can be found at: https://github.com/quarto-ext/
Extensions are project-specific installs, installed into _extensions
directory in your Quarto Project (or any directory where you want to affect quarto render
).
The Quarto team will develop extensions and host at quarto-ext
, but you can also download extensions from the community.
You can install extensions directly from Quarto!
quarto list extensions # list all installed extensions
quarto update extension quarto-ext/fontawesome # update specific extension
quarto remove extension quarto-ext/fontawesome # remove specific extension
If you are using version control you should check the _extensions directory in to your repo along with your other code. Installed extensions are treated as source code for your project to ensure very long term reproducibility—your project doesn’t need to rely on the availability of an external package manager (or the maintenance of older extension versions) to successfully render now and far into the future.
Quarto extensions may execute code when documents are rendered. If you do not
trust the authors of the extension, we recommend that you do not install or
use the extension.
? Do you trust the authors of this extension (Y/n) › Yes
[✓] Downloading
[✓] Unzipping
Found 1 extension.
The following changes will be made:
Font Awesome support [Install] 0.0.1 (shortcode)
? Would you like to continue (Y/n) › Yes
[✓] Extension installation complete.
Learn more about this extension at https://github.com/quarto-ext/fontawesome
fontawesome
There once was a who was lost at
He was rescued by a and a wee
Option | Description |
---|---|
desc-position |
The position of the title and description when displaying a lightbox. One of top , bottom , left , right . Defaults to bottom |
materials/workshop/08-knitr/lightbox-extension.qmd
Please complete the post-workshop survey. Your feedback is crucial! Data from the survey informs curriculum and format decisions for future conf workshops and we really appreciate you taking the time to provide it.
<rstd.io/conf-workshop-survey>