Skip to content

Commit

Permalink
Merge pull request #248 from fhdsl/update_data_viz_3
Browse files Browse the repository at this point in the history
Update data viz Lab
  • Loading branch information
carriewright11 authored Nov 14, 2024
2 parents dec9c46 + 8f6d044 commit 547268f
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions modules/Data_Visualization/lab/Data_Visualization_Lab_Key.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,17 @@ knitr::opts_chunk$set(echo = TRUE)

# Part 1

Load the libraries
Load the packages.

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

Load the CalEnviroScreen data from the link www.daseh.org/data/CalEnviroScreen_data.csv) and subset it so that you only have data from Fresno, Merced, Placer, Sonoma, and Yolo counties.

```{r}
ces <- read_csv("https://daseh.org/data/CalEnviroScreen_data.csv")
ces_sub <- ces %>% filter(CaliforniaCounty == c("Fresno", "Merced", "Placer", "Sonoma", "Yolo"))
ces_sub <- ces %>% filter(CaliforniaCounty %in% c("Fresno", "Merced", "Placer", "Sonoma", "Yolo"))
```

### 1.1
Expand Down Expand Up @@ -54,7 +52,7 @@ my_plot

### 1.2

"Update" your plot by adding a title and changing the x and y axis titles.
"Update" your plot by adding a title and changing the x and y axis titles. (Hint: use the `labs` function.)

```{r 1.2response}
my_plot <- my_plot +
Expand Down Expand Up @@ -126,7 +124,7 @@ ces_sub %>%
### 2.1
Let's look at the plot of traffic density and diesel particulate matter again,

Use `ggplot2` package make plot of how diesel particulate concentration (`DieselPM`; y-axis) is associated with traffic density values (`Traffic`; x-axis), where each county (`CaliforniaCounty`) has a different color (hint: use `color = type` in mapping).
Use `ggplot2` package make plot of how diesel particulate concentration (`DieselPM`; y-axis) is associated with traffic density values (`Traffic`; x-axis), where each county (`CaliforniaCounty`) has a different color (hint: use `color = CaliforniaCounty` in mapping).


```
Expand All @@ -152,11 +150,12 @@ ggplot(ces_sub, aes(

### 2.2

Redo the above plot by adding a faceting (`+ facet_wrap( ~ CaliforniaCounty, ncol = 3)`) to have data for quarter in a separate plot panel.

Redo the above plot by adding a faceting (`+ facet_wrap( ~ CaliforniaCounty, nrow = 3)`) to have data for quarter in a separate plot panel.

Assign the new plot as an object called `facet_plot`.

Try adjusting the number of rows in the `facet_wrap` to see how this changes the plot.

```{r 2.2response}
facet_plot <- ggplot(ces_sub, aes(
Expand All @@ -166,7 +165,7 @@ facet_plot <- ggplot(ces_sub, aes(
)) +
geom_line() +
geom_point() +
facet_wrap(~CaliforniaCounty, ncol = 3)
facet_wrap(~CaliforniaCounty, nrow = 3)
facet_plot
```
Expand Down

0 comments on commit 547268f

Please sign in to comment.