Lecture 17
Cornell University
INFO 3312/5312 - Spring 2024
March 26, 2024
---
title: Gun deaths
author: Your name
date: today
format: html
---
```{r}
#| label: setup
#| include: false
library(tidyverse)
library(rcis)
youth <- gun_deaths |>
filter(age <= 65)
```
# Gun deaths by age
We have data about `r nrow(gun_deaths)` individuals killed by guns. Only `r nrow(gun_deaths) - nrow(youth)` are older than 65. The distribution of the remainder is shown below:
```{r}
#| label: youth-dist
#| echo: false
ggplot(data = youth, mapping = aes(x = age)) +
geom_freqpoly(binwidth = 1)
```
# Gun deaths by race
```{r}
#| label: race-dist
youth |>
mutate(race = fct_infreq(race) |> fct_rev()) |>
ggplot(mapping = aes(y = race)) +
geom_bar() +
labs(y = "Victim race")
```
---
s```
eval: true
include: true
echo: true
message: true
or warning: true
cache: true
We have data about `r nrow(gun_deaths)` individuals killed by guns.
Only `r nrow(gun_deaths) - nrow(youth)` are older than 65. The distribution of the remainder is shown below:
We have data about 100798 individuals killed by guns.
Only 15687 are older than 65.
quarto
renders your .qmd
fileQuarto supports multiple presentation formats
revealjs
(HTML)pptx
(PowerPoint)beamer
(\(\LaTeX\)/PDF)format: html
+ a Quarto Projectformat: html
in that it has multiple pagesNo Quarto support (even math support is often nonexistent or awkward)
Huge benefits of static websites compared to dynamic websites
All static files, no PHP or databases, no login/password, work everywhere (even offline)
Typically fast to visit (no computation needed on the server side), and easy to speed up via CDN
File | Description |
---|---|
_quarto.yml |
Quarto project file. |
index.qmd |
Blog home page. |
about.qmd |
Blog about page. |
posts/ |
Directory containing posts |
posts/_metadata.yml |
Shared options for posts |
styles.css |
Custom CSS for website |
posts
directory/posts
- this folder will be the “slug” URL (like bensoltoff.com/my-new-post/
)index.qmd
within the new folderae-14
ae-14
(repo name will be suffixed with your GitHub name).These will preview the entire website
When you render the website, it will re-execute code in older posts. Not ideal in many situations!
index.qmd
together!You can use the freeze option to denote that computational documents should never be re-rendered during a global project render, or alternatively only be re-rendered when their source file changes
freeze: true
is typically added to a _metadata.yml
file within a specific directory, affecting all files in that directory.
In the case of a blog - the _metadata.yml
is saved at the root of the posts
directory. You can have it only within specific subdirectories for more complex sites.
Cache on the other hand, stores the results of computations for a specific file.
Note that cache invalidation is triggered by changes in chunk source code (or other cache attributes you’ve defined).
I typically use cache throughout various types of outputs when I have computationally expensive chunks.
Render index.qmd
in the project directory and note the items that are built
Explore the _freeze
directory
https://quarto.org/docs/websites/website-blog.html#themes
default, cerulean, cosmo, cyborg, darkly, flatly, journal, litera, lumen, lux, materia, minty, morph, pulse, quartz, sandstone, simplex, sketchy, slate, solar, spacelab, superhero, united, vapor, yeti, zephyr
_quarto.yml
and change the theme to one of the support Bootswatch themesposts/gun-deaths/index.qmd
in some wayabout.qmd
)your-proj/index.qmd
becomes your “home page”index.qmd
-> blog.qmd
and about.qmd
-> index.qmd
Type | Description |
---|---|
default | A blog style list of items. |
table | A table of listings. |
grid | A grid of listing cards. |
grid
index.qmd
Destination | Description |
---|---|
GitHub Pages | Publish content based on source code managed within a GitHub repository. Use GitHub Pages when the source code for your document or site is hosted on GitHub. |
RStudio Connect | Publishing platform for secure sharing of data products within an organization. Use RStudio Connect when you want to publish content within an organization rather than on the public internet. |
Netlify | Professional web publishing platform. Use Netlify when you want support for custom domains, authentication, previewing branches, and other more advanced capabilities. |
Other Services | Content rendered with Quarto uses standard formats (HTML, PDFs, MS Word, etc.) that can be published anywhere. Use this if one of the methods above don’t meet your requirements. |
quarto
R package: quarto::quarto_publish_???()
Evaluate R/Python code and render on a schedule
RStudio Connect
rsconnect::deployDoc(quarto = "path/to/quarto")
rsconnect::deployDoc(quarto = quarto::quarto_path())
quarto::quarto_publish_???()
quarto_publish_site(server = "rstudioconnect.example.com")
quarto_publish_doc(server = "rpubs.com")
quarto_publish_app(server = "shinyapps.io")
Similar to blog, but less of a focus on listing/posts and more focus on individual pages and overall navigation.
When you create a project, a _quarto.yml config file is created. Here is an example of what the _quarto.yml looks like:
_quarto.yml
A typical project is used to: