length(unique(whr$country_name))Quarto Documents
Slides
Exercises
Exercise 1
- Open
01-exercise-r.qmdor01-exercise-py.qmd. - Preview/render the document.
- Posit Cloud: You may be asked to allow pop-ups.
- Edit the title and preview/render again.
Exercise 2
- Open
01-exercise-r.qmdand run the first three code chunks (in order). - Preview the file.
- Add a
#| include: falsechunk option to the second chunk (global-trends). Preview the file and note the differences. - In the YAML, add an
authorfield and add your name. Preview the file. - Change
code-foldto betrue. Preview the file. - Edit the first paragraph to (1) make something bold by surrounding the text with
**and (2) use inline code instead of hardcoded values for the number of countries. You can use the following code to calculate the number of countries.
whr['country_name'].nunique()Exercise 3
- Add an
importantcallout box to the introduction summarizing the report’s findings. - In the first paragraph, link to the World Happiness Report website (https://www.worldhappiness.report/) where it says “2025 World Happiness Report”.
- Change some text to the color
"#eb068c".
Exercise 4
In the workshop repo, there’s a file named
04-exercise.yml. Rename the file to_brand.ymland rerender your Quarto document. What changes?Change some of the variables in the
_brand.ymlfile and rerender to see how your theme changes. You can reset the file by copying and pasting it from here.
Exercise 5
In the first code chunk of
01-exercise-r.qmd, replacetheme_minimal()withtheme_brand_ggplot2(). You will need to supply a brand file path ("_brand.yml").Re-render and see what changes.
In the first code chunk of
01-exercise-python.qmd, addtheme_brand_plotnine()right aftertheme_minimal(). You will need to supply a brand file path ("_brand.yml").Re-render. Does anything change? What if you change
foregroundin_brand.ymltohot-pink? Re-render with and withouttheme_brand_plotnine().
Exercise 6
- Read in
_brand.ymlwithread_brand_yml()(R) orBrand.from_yaml()(Python) to a variable namedbrand. - Change the color of the points and line in the global trends plot to the brand’s
tealcolor. Use code like the following.
(Make sure to first remove #| include: false from the chunk, if it’s still there).
geom_line(color = brand$color$palette$blue)geom_line(color = brand.color.palette.blue)