Skip to content

Instantly share code, notes, and snippets.

@dgkeyes
Created January 14, 2022 00:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgkeyes/f95c1dfd3d08721409b8b7cd0f9794f3 to your computer and use it in GitHub Desktop.
Save dgkeyes/f95c1dfd3d08721409b8b7cd0f9794f3 to your computer and use it in GitHub Desktop.
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