Skip to content

Commit

Permalink
Merge pull request #670 from jhudsl/manip-esquisse-updates
Browse files Browse the repository at this point in the history
Small tweaks to appearance/libs
  • Loading branch information
avahoffman authored Jan 13, 2025
2 parents 422fbf1 + 29ce05e commit 8d46289
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ output:

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(here)
library(tidyverse)
```

Expand All @@ -31,9 +30,9 @@ It's super **nifty**!
knitr::include_graphics("https://c.tenor.com/DNUSO9MjrTEAAAAC/bob-ross.gif")
```

## First, get some data..
## First, get some data.. {.codesmall}

We can use the CO heat-related ER visits dataset. This dataset contains information about the number and rate of visits for heat-related illness to ERs in Colorado from 2011-2022, adjusted for age.
We can use the CO heat-related ER visits dataset. This dataset contains information about the number and rate of visits for heat-related illness to Emergency rooms in Colorado from 2011-2022, adjusted for age.

```{r message=FALSE}
er <-
Expand Down Expand Up @@ -161,15 +160,15 @@ glimpse(long_er)

## Wide Data

As a comparison, let's also load a wide version of this dataset.
As a comparison, let's also load a wide version of this dataset. {.codesmall}

```{r}
wide_er <- read_csv(file =
"https://jhudatascience.org/intro_to_r/data/CO_heat_er_visits_DenverBoulder_wide.csv")
```

## Wide vs Long Data
## Wide vs Long Data: Which is better for plotting?

```{r}
head(long_er)
Expand Down Expand Up @@ -201,7 +200,9 @@ C. Both of these!

## Summary

* Use the `esquisser()` function on a dataset
* Use Esquisse:
* `library(esquisse)`
* `esquisser()` function on a dataset
* Use the `viewer = "browser"` argument to launch in your browser.
* Code from Esquisse can copied into code chunks to be generated in the "Plots" pane
* It's easier if your code is in "long" form!
Expand All @@ -214,7 +215,7 @@ C. Both of these!

📃 [Day 6 Cheatsheet](https://jhudatascience.org/intro_to_r/modules/cheatsheets/Day-6.pdf)

```{r, fig.alt="The End", out.width = "50%", echo = FALSE, fig.align='center'}
```{r, fig.alt="The End", out.width = "40%", echo = FALSE, fig.align='center'}
knitr::include_graphics(here::here("images/the-end-g23b994289_1280.jpg"))
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ install.packages("ggplot2")

```{r, comment = FALSE}
library(esquisse)
library(ggplot2)
library(tidyverse)
```

### 1.1
Expand Down
18 changes: 12 additions & 6 deletions modules/Manipulating_Data_in_R/Manipulating_Data_in_R.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ library(tidyverse)
- `separate()` can split columns into additional columns
- `unite()` can combine columns

📃[Cheatsheet](https://jhudatascience.org/intro_to_r/modules/cheatsheets/Day-5.pdf)
📃[Day 5 Cheatsheet](https://jhudatascience.org/intro_to_r/modules/cheatsheets/Day-5.pdf)

## Manipulating Data

Expand Down Expand Up @@ -123,7 +123,7 @@ Long: **Easier for R to make plots & do analysis**
ex_long
```

## Pivoting using `tidyr` package
## Pivoting using `tidyr` package (part of `tidyverse`)

`tidyr` allows you to "tidy" your data. We will be talking about:

Expand Down Expand Up @@ -181,10 +181,11 @@ ex_long <- ex_wide %>% pivot_longer(cols = ends_with("rate"),
ex_long
```

## Data used: Charm City Circulator
## Data used: Charm City Circulator {.codesmall}

```{r, message = FALSE}
circ <- read_csv("http://jhudatascience.org/intro_to_r/data/Charm_City_Circulator_Ridership.csv")
circ <-
read_csv("http://jhudatascience.org/intro_to_r/data/Charm_City_Circulator_Ridership.csv")
head(circ, 5)
```

Expand Down Expand Up @@ -213,6 +214,7 @@ Filter by Boardings only..

```{r}
long <- long %>% filter(str_detect(name, "Boardings"))
long
```

## Mission: Taking the average boardings by line
Expand Down Expand Up @@ -279,7 +281,7 @@ wide

## Summary

- `tidyr` package helps us convert between wide and long data
- `tidyr` package (part of `tidyverse`) helps us convert between wide and long data
- `pivot_longer()` goes from wide -> long
- Specify columns you want to pivot
- Specify `names_to = ` and `values_to = ` for custom naming
Expand Down Expand Up @@ -537,14 +539,18 @@ C. Using one data source is too easy and we want our analysis ~ fancy ~

💻 [Lab](https://jhudatascience.org/intro_to_r/modules/Manipulating_Data_in_R/lab/Manipulating_Data_in_R_Lab.Rmd)

~

📃 [Day 6 Cheatsheet](https://jhudatascience.org/intro_to_r/modules/cheatsheets/Day-6.pdf)

📃 [Posit's `tidyr` Cheatsheet](https://rstudio.github.io/cheatsheets/tidyr.pdf)

📃 [Posit's `dplyr` Cheatsheet](https://rstudio.github.io/cheatsheets/data-transformation.pdf)

🔎️ [Joining Open Case Study](https://www.opencasestudies.org/ocs-bp-diet/)


```{r, fig.alt="The End", out.width = "50%", echo = FALSE, fig.align='center'}
```{r, fig.alt="The End", out.width = "20%", echo = FALSE, fig.align='center'}
knitr::include_graphics(here::here("images/the-end-g23b994289_1280.jpg"))
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ knitr::opts_chunk$set(echo = TRUE)
Data in this lab comes from the CDC (https://covid.cdc.gov/covid-data-tracker/#vaccinations_vacc-total-admin-rate-total - snapshot from January 12, 2022) and the Bureau of Economic Analysis (https://www.bea.gov/data/income-saving/personal-income-by-state).

```{r message=FALSE}
library(readr)
library(dplyr)
library(tidyr)
library(tidyverse)
```

# Part 1
Expand Down

0 comments on commit 8d46289

Please sign in to comment.