Skip to content

Commit

Permalink
Merge pull request #44 from fhdsl/esquisse
Browse files Browse the repository at this point in the history
[Esquisse] updating datasets
  • Loading branch information
ehumph authored Jul 2, 2024
2 parents 9cfb6ce + e4dad69 commit a4599dc
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 41 deletions.
25 changes: 25 additions & 0 deletions data/CO_heat_er_visits_DenverBoulder_long.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
county,rate,year
Boulder,4.034535158,2011
Boulder,4.079100661,2012
Boulder,3.792547926,2013
Boulder,6.290257722,2014
Boulder,4.75554403,2015
Boulder,5.67667787,2016
Boulder,3.509452842,2017
Boulder,5.07284974,2018
Boulder,3.706147494,2019
Boulder,3.641104794,2020
Boulder,5.512484465,2021
Boulder,5.484898507,2022
Denver,7.114236027,2011
Denver,6.793702395,2012
Denver,2.945863431,2013
Denver,3.556912499,2014
Denver,3.843781154,2015
Denver,6.182937234,2016
Denver,3.315020838,2017
Denver,5.805259516,2018
Denver,4.537265998,2019
Denver,4.422048886,2020
Denver,3.84747781,2021
Denver,6.475106589,2022
3 changes: 3 additions & 0 deletions data/CO_heat_er_visits_DenverBoulder_wide.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
county,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022
Boulder,4.034535158,4.079100661,3.792547926,6.290257722,4.75554403,5.67667787,3.509452842,5.07284974,3.706147494,3.641104794,5.512484465,5.484898507
Denver,7.114236027,6.793702395,2.945863431,3.556912499,3.843781154,6.182937234,3.315020838,5.805259516,4.537265998,4.422048886,3.84747781,6.475106589
23 changes: 13 additions & 10 deletions modules/Esquisse_Data_Visualization/Esquisse_Data_Visualization.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -143,36 +143,39 @@ knitr::include_graphics("images/stop.png")

## Wide & Long Data Example

Let's examine a subset of the dataset for heat-related ER visits in Colorado, showing only data for Boulder and Denver counties.

```{r message=FALSE}
library(jhur)
library(dasehr)
library(dplyr)
wide_circ <- read_circulator()
glimpse(wide_circ)
wide_heat <- CO_heat_ER_wide
glimpse(wide_heat)
```

## Long Data

```{r}
library(tidyr)
long_circ <- wide_circ %>%
long_heat <- wide_heat %>%
pivot_longer(
cols = contains(c("boarding")),
names_to = "Route",
values_to = "Boardings"
cols = starts_with("20"),
names_to = "year",
values_to = "visit_rate"
)
```

## Long Data

```{r}
glimpse(long_circ)
glimpse(long_heat)
```

## Make a plot of boardings by day for different routes

```{r, eval = FALSE}
esquisser(wide_circ) # days as x...? Tricky!
esquisser(long_circ) # day as x, Boardings as y, Route as fill
esquisser(wide_heat) # days as x...? Tricky!
esquisser(long_heat) # day as x, Boardings as y, Route as fill
```

## Some Alternatives to `esquisse`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,55 @@ install.packages("ggplot2")
```{r, comment = FALSE}
library(esquisse)
library(ggplot2)
library(jhur)
library(dplyr)
library(dasehr)
```

### 1.1

Try creating a plot using the `Orange` data that automatically comes with R using the `esquisse` package.
Try creating a plot in `esquisse` using the `calenviroscreen` data from the `dasehr` packaged. This dataset has a lot of variables, so first run the below code to subset it so that you're only working with these variables: `CES4.0Percentile`, `Asthma`, and `ChildrenPercLess10`. We will also categorize `CES4.0Percentile` into three categories (high, middle, and low) to make visualization a little easier!

- Drag and drop the `age` variable to be plotted on the x-axis.
- Drag and drop the `circumference` variable to be plotted on the y-axis.
- What happens when you drag `tree` to the facet region of the esquisse GUI?
```{r}
ces_sub <- select(calenviroscreen, c("CES4.0Percentile", "Asthma", "ChildrenPercLess10"))
ces_sub <- ces_sub %>%
mutate(CES4.0Perc_cat =
case_when(CES4.0Percentile > 75 ~ "High",
CES4.0Percentile <= 75 & CES4.0Percentile >25 ~ "Middle",
CES4.0Percentile <= 25 ~ "Low"))
```

- Drag and drop the `ChildrenPercLess10` variable to be plotted on the x-axis.
- Drag and drop the `Asthma` variable to be plotted on the y-axis.
- What happens when you drag `CES4.0Perc_cat` to the facet region of the esquisse GUI?
- What happens if you move this to color?
- Copy and paste the code from both options into the chunk below:

```{r 1.1response}
# esquisser(ces_sub)
ggplot(ces_sub) +
aes(x = ChildrenPercLess10, y = Asthma) +
geom_point(shape = "circle", size = 1.5, colour = "#112446") +
theme_minimal() +
facet_wrap(vars(CES4.0Perc_cat))
ggplot(ces_sub) +
aes(x = ChildrenPercLess10, y = Asthma, colour = CES4.0Perc_cat) +
geom_point(shape = "circle", size = 1.5) +
scale_color_hue(direction = 1) +
theme_minimal()
```

### 1.2

Click where it says "point" (may say "auto" depending on how you did the last question) on the far left side and change the plot to a different type of plot. Copy and paste the code into the chunk below. Close Esquisse and run the chunk below to generate a ggplot.

```{r 1.2response}
ggplot(ces_sub) +
aes(x = ChildrenPercLess10, y = Asthma, colour = CES4.0Perc_cat) +
geom_line(size = 0.5) +
scale_color_hue(direction = 1) +
theme_minimal()
```


Expand All @@ -46,11 +72,13 @@ Click where it says "point" (may say "auto" depending on how you did the last qu
Launch Esquisse on any selection of the following datasets we have worked with before and explore!

```{r}
yts <- read_yts()
tb <- read_tb()
bike <- read_bike()
circ <- read_circulator()
vacc <- read_csv("https://daseh.org/data/USA_covid19_vaccinations.csv")
covid_wastewater
CO_heat_ER
CO_heat_ER_byage
CO_heat_ER_bygender
yearly_co2_emissions
nitrate
haa5
```

```{r P.1response}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,40 @@ install.packages("ggplot2")
```{r, comment = FALSE}
library(esquisse)
library(ggplot2)
library(jhur)
library(dplyr)
library(dasehr)
```

### 1.1

Try creating a plot using the `Orange` data that automatically comes with R using the `esquisse` package.
Try creating a plot in `esquisse` using the `calenviroscreen` data from the `dasehr` packaged. This dataset has a lot of variables, so first run the below code to subset it so that you're only working with these variables: `CES4.0Percentile`, `Asthma`, and `ChildrenPercLess10`. We will also categorize `CES4.0Percentile` into three categories (high, middle, and low) to make visualization a little easier!

- Drag and drop the `age` variable to be plotted on the x-axis.
- Drag and drop the `circumference` variable to be plotted on the y-axis.
- What happens when you drag `tree` to the facet region of the esquisse GUI?
```{r}
ces_sub <- select(calenviroscreen, c("CES4.0Percentile", "Asthma", "ChildrenPercLess10"))
ces_sub <- ces_sub %>%
mutate(CES4.0Perc_cat =
case_when(CES4.0Percentile > 75 ~ "High",
CES4.0Percentile <= 75 & CES4.0Percentile >25 ~ "Middle",
CES4.0Percentile <= 25 ~ "Low"))
```

- Drag and drop the `ChildrenPercLess10` variable to be plotted on the x-axis.
- Drag and drop the `Asthma` variable to be plotted on the y-axis.
- What happens when you drag `CES4.0Perc_cat` to the facet region of the esquisse GUI?
- What happens if you move this to color?
- Copy and paste the code from both options into the chunk below:

```{r 1.1response}
# esquisser(Orange)
ggplot(Orange) +
aes(x = age, y = circumference) +
# esquisser(ces_sub)
ggplot(ces_sub) +
aes(x = ChildrenPercLess10, y = Asthma) +
geom_point(shape = "circle", size = 1.5, colour = "#112446") +
theme_minimal() +
facet_wrap(vars(Tree))
facet_wrap(vars(CES4.0Perc_cat))
ggplot(Orange) +
aes(x = age, y = circumference, colour = Tree) +
ggplot(ces_sub) +
aes(x = ChildrenPercLess10, y = Asthma, colour = CES4.0Perc_cat) +
geom_point(shape = "circle", size = 1.5) +
scale_color_hue(direction = 1) +
theme_minimal()
Expand All @@ -46,8 +57,8 @@ ggplot(Orange) +
Click where it says "point" (may say "auto" depending on how you did the last question) on the far left side and change the plot to a different type of plot. Copy and paste the code into the chunk below. Close Esquisse and run the chunk below to generate a ggplot.

```{r 1.2response}
ggplot(Orange) +
aes(x = age, y = circumference, colour = Tree) +
ggplot(ces_sub) +
aes(x = ChildrenPercLess10, y = Asthma, colour = CES4.0Perc_cat) +
geom_line(size = 0.5) +
scale_color_hue(direction = 1) +
theme_minimal()
Expand All @@ -61,13 +72,15 @@ ggplot(Orange) +
Launch Esquisse on any selection of the following datasets we have worked with before and explore!

```{r}
yts <- read_yts()
tb <- read_tb()
bike <- read_bike()
circ <- read_circulator()
vacc <- read_csv("https://daseh.org/data/USA_covid19_vaccinations.csv")
covid_wastewater
CO_heat_ER
CO_heat_ER_byage
CO_heat_ER_bygender
yearly_co2_emissions
nitrate
haa5
```

```{r P.1response}
# esquisser(vacc)
# esquisser(nitrate)
```

0 comments on commit a4599dc

Please sign in to comment.