From 590786aa183fe32d422acc4c4e657c7b148d5445 Mon Sep 17 00:00:00 2001 From: mattbk Date: Tue, 9 Jan 2024 19:49:07 -0600 Subject: [PATCH] Update plots. --- bin/data-plots.R | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/bin/data-plots.R b/bin/data-plots.R index bb32300..d256fe0 100644 --- a/bin/data-plots.R +++ b/bin/data-plots.R @@ -7,7 +7,7 @@ library(ggthemes) # Read in data from Wayback Machine archive of http://www.arrl.org/fcc-license-counts -d_raw <- read.csv("data/arrl us ham radio licenses over time.csv") +d_raw <- read.csv("data/us ham radio licenses over time.csv") # What dates do we have? unique(d_raw$Date) @@ -15,12 +15,15 @@ unique(d_raw$Date) # Clean up here if needed d <- d_raw %>% mutate(Date = as.Date(Date)) %>% - mutate(across(c(3:9), as.numeric)) + # Drop Tech alone and leave Tech and Tech Plus + select(-c(Tech, Tech.Plus)) %>% + mutate(across(c(3:8), as.numeric)) + d_total <- d %>% filter(State.Territory == "TOTAL") d_total_long <- d_total %>% - pivot_longer(cols = 3:9, + pivot_longer(cols = 3:8, names_to = "lclass", values_to = "count") @@ -29,33 +32,37 @@ d_total_long <- d_total %>% ##### Total over time ##### ggplot(data = d_total, aes(x = Date, - y = Total)) + + y = Total, + color = source_name)) + geom_line() + geom_point() + - scale_x_date(date_breaks = "1 year", - date_minor_breaks = "1 month", + scale_x_date(date_breaks = "10 years", + date_minor_breaks = "1 year", date_labels = "%Y") + scale_y_continuous(labels = scales::comma) + theme_bw() + labs(title = "US Amateur Licenses", - subtitle = "http://www.arrl.org/fcc-license-counts, Wayback Machine", - caption = "w1cdn.net") + subtitle = "ARRL, AH0A", + caption = "w1cdn.net", + color = "Source") ##### Total over time, y = 0 ##### ggplot(data = d_total, aes(x = Date, - y = Total)) + + y = Total, + color = source_name)) + geom_line() + geom_point() + - scale_x_date(date_breaks = "1 year", - date_minor_breaks = "1 month", + scale_x_date(date_breaks = "10 years", + date_minor_breaks = "1 year", date_labels = "%Y") + scale_y_continuous(labels = scales::comma, limits = c(0, NA)) + theme_bw() + labs(title = "US Amateur Licenses", - subtitle = "http://www.arrl.org/fcc-license-counts, Wayback Machine", - caption = "w1cdn.net") + subtitle = "ARRL, AH0A", + caption = "w1cdn.net", + color = "Source") ##### By license class ##### ggplot(data = d_total_long %>% filter(lclass != "Total"), @@ -64,14 +71,14 @@ ggplot(data = d_total_long %>% filter(lclass != "Total"), color = fct_reorder2(lclass, Date, count))) + geom_line() + geom_point() + - scale_x_date(date_breaks = "1 year", - date_minor_breaks = "1 month", + scale_x_date(date_breaks = "10 years", + date_minor_breaks = "1 year", date_labels = "%Y") + scale_y_continuous(labels = scales::comma) + scale_color_colorblind() + theme_bw() + labs(title = "US Amateur Licenses by Class", - subtitle = "http://www.arrl.org/fcc-license-counts, Wayback Machine", + subtitle = "ARRL, AH0A", y = "Count", color = "Class", caption = "w1cdn.net") @@ -83,13 +90,13 @@ ggplot(data = d_total_long %>% filter(lclass != "Total"), fill = fct_reorder2(lclass, Date, count))) + geom_area() + scale_fill_colorblind() + - scale_x_date(date_breaks = "1 year", - date_minor_breaks = "1 month", + scale_x_date(date_breaks = "10 years", + date_minor_breaks = "1 year", date_labels = "%Y") + scale_y_continuous(labels = scales::comma) + theme_bw() + labs(title = "US Amateur Licenses by Class", - subtitle = "http://www.arrl.org/fcc-license-counts, Wayback Machine", + subtitle = "ARRL, AH0A", fill = "Class", caption = "w1cdn.net")