-
-
Save dgkeyes/f95c1dfd3d08721409b8b7cd0f9794f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
enrollment_by_race_ethnicity <- read_rds("data/enrollment-by-race-ethnicity.rds") | |
# Original Solution ------------------------------------------------------- | |
highlight_district <- enrollment_by_race_ethnicity %>% | |
filter(race_ethnicity == "Hispanic/Latino") %>% | |
filter(district == "Douglas ESD") | |
enrollment_by_race_ethnicity %>% | |
filter(race_ethnicity == "Hispanic/Latino") %>% | |
ggplot(aes(x = year, | |
y = percent_of_total_at_school, | |
group = district)) + | |
geom_line(color = "lightgray", | |
alpha = 0.5) + | |
geom_line(data = highlight_district, | |
inherit.aes = TRUE, | |
color = "blue") + | |
labs(title = "Douglas ESD") | |
# Function ---------------------------------------------------------------- | |
highlight_district_plot <- function(race_ethnicity_filter, district_filter) { | |
highlight_district <- enrollment_by_race_ethnicity %>% | |
filter(race_ethnicity == race_ethnicity_filter) %>% | |
filter(district == district_filter) | |
enrollment_by_race_ethnicity %>% | |
filter(race_ethnicity == race_ethnicity_filter) %>% | |
ggplot(aes(x = year, | |
y = percent_of_total_at_school, | |
group = district)) + | |
geom_line(color = "lightgray", | |
alpha = 0.5) + | |
geom_line(data = highlight_district, | |
inherit.aes = TRUE, | |
color = "blue") + | |
labs(title = district_filter) | |
} | |
highlight_district_plot(race_ethnicity_filter = "Hispanic/Latino", | |
district_filter = "Adrian SD 61") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment