using Tidier, RDatasets
# Set these in notebook environments to prevent opening plots after every render
TidierPlots_set("plot_show", false);
TidierPlots_set("plot_log", false);
= @chain dataset("datasets", "mtcars") begin
mtcars @clean_names
@mutate(cyl_factor = string(cyl))
end
@chain mtcars begin
ggplot(@aes(x = wt, y = mpg, color = cyl_factor))
# ggplot(aes(x = :wt, y = :mpg, color = :cyl_factor))
geom_point()
geom_smooth()
labs(
# color = "Cylinders", # not yet implemented in Tidier.jl
= "Weight",
x = "Miles per gallon"
y
)end
Unlike RMarkdown
, Quarto strives to be language agnostic. From the documentation on computation within Quarto for Julia:
Quarto has two available engines for executing Julia code. The older one is using the IJulia Jupyter kernel and depends on Python to run. The newer engine is using the QuartoNotebookRunner.jl package to render notebooks and does not have any additional dependencies beyond a Julia installation.
To use QuartoNotebookRunner.jl
, include engine: julia
in the Quarto document’s yaml
header.
Here’s a test of including julia
code in a blog post created with Quarto
. It’s also an example of using Tidier.jl, which is great for someone coming from a tidyverse
background:
Tidier.jl is a data analysis package inspired by R’s tidyverse and crafted specifically for Julia. Tidier.jl is a meta-package in that its functionality comes from a series of smaller packages. Installing and using Tidier.jl brings the combined functionality of each of these packages to your fingertips.
{julia}
code cell in Quarto:
I was not able to specify column width using #| column: page-right
within the {julia}
code chunk. Instead, had to use fenced divs; i.e. ::: {.column-page-right} {code chunk} :::
Other than that, looks good!
Additional notes
- used Positron IDE
- Quarto HTML
link-external-newwindow: true
in YAML header – all links should open in new window - use a site-wide directory as source for image
- Alfred App text expansion to template a blog post, including current date
- In VS Code, added context-aware keyboard shortcut to add Julia codeblock:
Preferences: Open Keyboard Shortcuts (JSON): keybindings.json
{
"key": "alt+cmd+i",
"command": "type",
"when": "editorLangId == 'quarto' && julia.isActiveREPL",
"args": { "text": "\n```{julia}\n\n```\n" }
}