Created
November 9, 2022 09:25
-
-
Save jonspring/a005f2c231aa507afbf1a65db8667e9a to your computer and use it in GitHub Desktop.
This file contains hidden or 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) | |
library(zipcodeR) | |
tuesdata <- tidytuesdayR::tt_load('2022-11-08') | |
state_stations <- tuesdata$state_stations | |
station_info <- tuesdata$station_info | |
zipcodeR::zip_code_db -> zips | |
state_stations %>% | |
separate(frequency, c("freq", "band"), sep = " ", convert = TRUE, remove = FALSE) %>% | |
mutate(band = if_else(band == "", NA_character_, band)) %>% | |
mutate(band = coalesce(band, if_else(freq > 500, "AM", "FM"))) %>% | |
left_join(data.frame(state_init = state.abb, state = state.name)) %>% | |
left_join(zipcodeR::zip_code_db %>% | |
group_by(state, major_city) %>% | |
slice_max(population), | |
by = c("state_init" = "state", "city" = "major_city")) -> station_context | |
station_context %>% | |
mutate(format_lmp = fct_lump(format, n = 8) %>% coalesce("Other") %>% fct_infreq()) %>% | |
mutate(call_short = str_sub(call_sign, 1, 4)) %>% | |
filter(lng > -130, lat < 80) %>% | |
filter(format_lmp %in% c("Country", "News/Talk", "Adult contemporary")) %>% | |
ggplot(aes(lng, lat, label = call_short, color = format_lmp)) + | |
ggrepel::geom_text_repel(size = 1.2, max.overlaps = 10, max.iter = 30000, | |
min.segment.length = Inf, point.size = NA, box.padding = 0, | |
key_glyph = "point", family = "Inter") + | |
ggthemes::scale_color_tableau(name = NULL) + | |
guides(color = guide_legend(override.aes = aes(label = "", shape = 19, size = 6))) + | |
theme_void(base_family = "Inter") + | |
coord_map("bonne", lat0 = 50) + | |
theme(legend.position = c(0.2, 0.2)) | |
ggsave("call_signs_3.png", device = ragg::agg_png, res = 300, width = 16, height = 9, scale = 0.8, bg = "white") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment