Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small tweaks to appearance/libs #670

Merged
merged 3 commits into from
Jan 13, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Small tweaks to appearance/libs
avahoffman committed Jan 13, 2025
commit 1c0d085e90022e15492ae19354779d46a35bdffa
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ output:

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

@@ -31,7 +30,7 @@ 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.

@@ -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)
@@ -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!
@@ -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"))
```

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

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

### 1.1
12 changes: 7 additions & 5 deletions modules/Manipulating_Data_in_R/Manipulating_Data_in_R.Rmd
Original file line number Diff line number Diff line change
@@ -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

@@ -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:

@@ -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)
```

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

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

## Mission: Taking the average boardings by line
@@ -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
Original file line number Diff line number Diff line change
@@ -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