Skip to content

Commit

Permalink
fix up worksheet
Browse files Browse the repository at this point in the history
  • Loading branch information
clauswilke committed Dec 26, 2024
1 parent 88593f4 commit 2643353
Show file tree
Hide file tree
Showing 38 changed files with 28,692 additions and 15 deletions.
8 changes: 4 additions & 4 deletions slides/telling-a-story.html
Original file line number Diff line number Diff line change
Expand Up @@ -390,16 +390,16 @@ <h2>Every story needs an arc</h2>
</section>
<section id="mapping-my-story-onto-this-format" class="slide level2">
<h2>Mapping my story onto this format</h2>
<div class="fragment move-down-1em">
<div class="fragment small-font move-down-1em">
<p><strong>Opening:</strong> We need to make many data visualizations in my lab</p>
</div>
<div class="fragment move-down-1em">
<div class="fragment small-font move-down-1em">
<p><strong>Challenge:</strong> I end up telling my students the same things over and over</p>
</div>
<div class="fragment move-down-1em">
<div class="fragment small-font move-down-1em">
<p><strong>Action:</strong> I go and write a book about data visualization</p>
</div>
<div class="fragment move-down-1em">
<div class="fragment small-font move-down-1em">
<p><strong>Resolution:</strong> The book is written. But now I teach the material, so I still keep saying the same things over and over</p>
</div>
</section>
Expand Down
8 changes: 4 additions & 4 deletions slides/telling-a-story.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,19 @@ Challenge and resolution are<br>the two most important parts

## Mapping my story onto this format

::: {.fragment .move-down-1em}
::: {.fragment .small-font .move-down-1em}
**Opening:** We need to make many data visualizations in my lab
:::

::: {.fragment .move-down-1em}
::: {.fragment .small-font .move-down-1em}
**Challenge:** I end up telling my students the same things over and over
:::

::: {.fragment .move-down-1em}
::: {.fragment .small-font .move-down-1em}
**Action:** I go and write a book about data visualization
:::

::: {.fragment .move-down-1em}
::: {.fragment .small-font .move-down-1em}
**Resolution:** The book is written. But now I teach the material, so I still keep saying the same things over and over
:::

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1,113 changes: 1,113 additions & 0 deletions worksheets/aesthetic-mappings.html

Large diffs are not rendered by default.

25 changes: 18 additions & 7 deletions worksheets/aesthetic-mappings.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,26 @@ format: live-html
engine: knitr
---

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

## Introduction

In this worksheet, we will discuss a core concept of ggplot, the mapping of data values onto aesthetics.

First we need to load the required R packages and the data. Please run this code to ensure the subsequent exercises work.
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.

```{webr}
#| warning: false
# load required library
#| edit: false
library(tidyverse)
library(DT)
```

Next we set up the data.

# data prep
```{webr}
#| edit: false
#| warning: false
temperatures <- read_csv("https://wilkelab.org/SDS375/datasets/tempnormals.csv") |>
mutate(
location = factor(
Expand All @@ -32,7 +38,9 @@ temps_houston <- filter(temperatures, location == "Houston")

We will first work with the dataset `temps_houston` which contains the average temperature for each day of the year for Houston, TX.
```{webr}
temps_houston
#| edit: false
#| autorun: true
datatable(temps_houston)
```

## Basic use of ggplot
Expand Down Expand Up @@ -148,9 +156,12 @@ ggplot(temps_houston, aes(x = temperature, y = month)) +

## Adding color

Next we will be working with the dataset `temperatures`, which is similar to `temps_houston` but contains data for three more locations:
Next we will be working with the dataset `temperatures`, which is similar to `temps_houston` but contains data for three more locations.

```{webr}
temperatures
#| edit: false
#| autorun: true
datatable(temperatures)
```

Make a line plot of `temperature` against `day_of_year`, using the `color` aesthetic to color the lines by location.
Expand Down
Loading

0 comments on commit 2643353

Please sign in to comment.