Example worksheet

Author

Claus O. Wilke

First we need to load the required R packages. Please wait a moment until the live R session is fully set up and all packages are loaded.

Next we take a look at the data. We’ll be working with the penguins dataset from the palmerpenguins package.

Now make a scatter plot of bill length versus body mass, coloring the points by penguin species.

Hint 1

The dataset is provided as the argument to the ggplot() function.

ggplot(penguins) +
  aes(___) +
  ___()
Hint 2

The variable body_mass_g goes on the x axis, the variable bill_length_mm goes on the y axis, and species is used to assign color.

ggplot(penguins) +
  aes(body_mass_g, bill_length_mm, color = species) +
  ___()
Solution

The complete code to make the requested scatter plot. Use na.rm = TRUE to avoid warnings about missing data values.

ggplot(penguins) +
  aes(body_mass_g, bill_length_mm, color = species) +
  geom_point(na.rm = TRUE)


Installation and setup

To enable live R exercises in your own Quarto documents, install the quarto-live extension:

quarto add r-wasm/quarto-live

For any worksheet that you want to contain live exercises, you need to set the format to live-html in the YAML header. If you’re an R user, you probably also want to use the knitr engine instead of the jupyter engine, which you can select with the engine setting. To use the knitr engine, you also need to include a custom quarto file that comes with the Quarto-live extension.

---
format: live-html
engine: knitr
---

{{< include ./_extensions/r-wasm/live/_knitr.qmd >}}

For more documentation on the quarto live extension, see here: https://r-wasm.github.io/quarto-live/

You can also check out the source of this interactive worksheet here: https://github.com/clauswilke/PositConf2025/blob/main/worksheets/worksheet.qmd