Add a bit more data, update plots.

This commit is contained in:
mattbk
2024-01-22 22:31:45 -06:00
parent 694ca425a3
commit 0b7e9db564
7 changed files with 68 additions and 5 deletions

View File

@ -7,9 +7,10 @@ library(ggthemes)
library(plotly)
library(htmlwidgets)
library(lubridate)
library(ggrepel)
# Read in data from Wayback Machine archive of http://www.arrl.org/fcc-license-counts
#### Total/State/Class ####
# Read in total/state/class data
d_raw <- read.csv("data/us ham radio licenses over time.csv")
# What dates do we have?
@ -33,6 +34,11 @@ d_total_long <- d_total %>%
d_state_total_long <- d %>% filter(State.Territory != "TOTAL") %>%
select(Date, State.Territory, Total, source_name, source_detail) %>%
filter(!is.na(Total))
#### City ####
city_raw <- read.csv("data/us cities ham radio licenses over time.csv")
city <- city_raw %>% mutate(Date = as.Date(Date),
city_label = paste0(City, ", ", State))
#### Plots ####
@ -200,3 +206,54 @@ ggplot(data = d_state_total_long,
theme(legend.position="bottom")
ggsave("plots/states-over-time-freey.png", width = 15, height = 9)
##### By city #####
a <- city %>% group_by(city_label) %>%
mutate(plot_label = if_else(Date == max(Date),
city_label,
NA_character_))
ggplot(data = a,
aes(x = Date,
y = Count,
color = city_label)) +
geom_line() +
geom_point(size = 0.3) +
scale_x_date(date_breaks = "1 years",
date_minor_breaks = "1 month",
date_labels = "%Y",
limits = c(NA_Date_, Sys.Date() + years(4))) +
scale_y_continuous(labels = scales::comma) +
theme_bw() +
geom_label_repel(aes(label = plot_label),
nudge_x = 1,
na.rm = TRUE,
segment.colour = NA) +
labs(title = "US Amateur Licenses by City",
y = "Count",
caption = "w1cdn.net") +
theme(legend.position="bottom") +
guides(color = "none")
ggsave("plots/cities-over-time.png", width = 15, height = 9)
##### By city, free y #####
ggplot(data = city,
aes(x = Date,
y = Count,
group = city_label)) +
geom_line() +
geom_point(size = 0.3) +
facet_wrap(~city_label,
scales = "free_y"
) +
scale_x_date(date_breaks = "4 years",
date_minor_breaks = "1 years",
date_labels = "%Y") +
scale_y_continuous(labels = scales::comma) +
theme_bw() +
labs(title = "US Amateur Licenses by City",
y = "Count",
caption = "w1cdn.net") +
theme(legend.position="bottom")
ggsave("plots/cities-over-time-freey.png", width = 15, height = 9)