Compare commits

...

2 Commits

Author SHA1 Message Date
mattbk
9f46e49b10 Add data and update plots. 2024-09-20 21:30:52 -05:00
mattbk
6177bd0b6d Scrape AE7Q states. 2024-09-20 20:36:57 -05:00
11 changed files with 91 additions and 12 deletions

View File

@ -6,6 +6,7 @@ library(tidyr)
# sudo crontab -e
# 5 9 * * * su matt -c "cd /home/matt/ham-radio-licenses/; Rscript /home/matt/ham-radio-licenses/scrape-license-counts.R">/dev/null 2>&1
###### ARRL ######
arrl_url <- "https://www.arrl.org/fcc-license-counts"
# Read the page
@ -137,20 +138,32 @@ ae7q_raw <- read_html(ae7q_url)
ae7q_tables <- ae7q_raw %>%
html_elements(xpath = "//table") %>%
html_table()
ae7q_table_state <- ae7q_tables[[20]]
ae7q_table_state_raw <- ae7q_tables[[20]]
# Fix names
names(ae7q_table_state) <- ae7q_table_state[1,]
ae7q_table_state <- ae7q_table_state[-1,]
# TODO
# split percents out into other columns (separate_wider_delim() ?)
# etc.
names(ae7q_table_state_raw) <- ae7q_table_state_raw[1,]
ae7q_table_state_raw <- ae7q_table_state_raw[-1,]
ae7q_table_state <- ae7q_table_state_raw %>%
pivot_longer(cols = -"State or Territory") %>%
# remove percentages
mutate(value = gsub("\\s*\\([^\\)]+\\)", "", value)) %>%
pivot_wider(id_cols = "State or Territory") %>%
# Split states
separate(`State or Territory`,
into = c("state_code", "state_name"),
sep = " - ",
fill = "right") %>%
mutate(state_name = case_when(state_code == "-" ~ "Other*",
state_code == "Totals" ~ "TOTAL",
TRUE ~ state_name)) %>%
# Organize
select(c(-GeoRegion, -state_code)) %>%
mutate(date = Sys.Date(),
ttp=NA, conditional=NA, military=NA, multiple=NA, repeater=NA,
gmrs=NA, source="AE7Q", source_detail=ae7q_url) %>%
relocate(date, state_name, Novice, Technician, TechnicianPlus,
General, Advanced, AmateurExtra, Total, ttp, conditional,
Club)
##### Append tables #####
write.table(hamcall_table_class_pivot, file = "out/hamcall-licenses-scraped.csv", sep = ",",
@ -167,3 +180,8 @@ write.table(hamcall_table_state, file = "out/hamcall-states-scraped.csv", sep =
append = TRUE, quote = FALSE,
col.names = F, row.names = FALSE,
na = "")
write.table(ae7q_table_state, file = "out/ae7q-states-scraped.csv", sep = ",",
append = TRUE, quote = FALSE,
col.names = F, row.names = FALSE,
na = "")

View File

@ -19720,3 +19720,64 @@ Date,State/Territory,Novice,Tech,Tech-Plus,General,Advanced,Extra,Total,Tech_and
1996-09-01,Virgin Islands,,,,,,,369,,,,,,,,FCC-W5YI,https://archive.org/details/1996-09-15_W5YI_Report/page/63/mode/2up
1996-09-01,Other*,,,,,,,903,,,,,,,,FCC-W5YI,https://archive.org/details/1996-09-15_W5YI_Report/page/63/mode/2up
1996-09-01,TOTAL,89833,156909,149244,128180,117518,74149,713822,,,,,,,,FCC-W5YI,https://archive.org/details/1996-09-15_W5YI_Report/page/63/mode/2up
2024-09-20,Armed Forces Americas,0,1,0,1,0,1,3,,,0,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Armed Forces Europe,1,84,0,42,3,48,178,,,0,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Alaska,18,1769,0,966,152,712,3692,,,75,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Alabama,72,6215,0,3454,559,3102,13641,,,239,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Armed Forces Pacific,0,82,0,19,2,26,130,,,1,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Arkansas,41,4723,0,2165,341,1747,9155,,,138,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,American Samoa,0,2,0,5,1,11,22,,,3,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Arizona,118,12443,0,5509,1063,4876,24264,,,255,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,California,754,65665,0,20863,3631,16539,108912,,,1460,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Colorado,101,11760,0,4844,735,3991,21651,,,220,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Connecticut,128,3577,0,2036,406,1766,8081,,,168,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,District of Columbia,4,286,0,125,21,128,576,,,12,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Delaware,20,877,0,551,89,444,2016,,,35,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Florida,479,20831,0,12945,2723,10761,48328,,,589,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Georgia,123,9914,0,5383,893,4432,21131,,,386,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Guam,1,110,0,52,8,106,289,,,12,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Hawaii,29,2237,0,816,151,719,4084,,,132,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Iowa,60,3318,0,1811,415,1593,7308,,,111,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Idaho,30,7180,0,2758,261,1765,12087,,,93,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Illinois,271,9561,0,5633,1055,4664,21525,,,341,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Indiana,172,8171,0,4503,752,3407,17301,,,296,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Kansas,73,3846,0,2106,306,1647,8110,,,132,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Kentucky,79,5265,0,2812,429,2180,10915,,,150,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Louisiana,62,2954,0,1860,361,1457,6843,,,149,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Massachusetts,165,6487,0,3729,688,3454,14786,,,263,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Maryland,107,5393,0,3012,571,2835,12100,,,182,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Maine,39,2138,0,1369,222,1193,5054,,,93,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Michigan,188,11022,0,5770,1051,4976,23357,,,350,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Minnesota,114,5874,0,3230,628,2656,12685,,,183,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Missouri,101,8432,0,4204,672,3297,16970,,,264,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Northern Mariana Islands,0,135,0,40,1,127,321,,,18,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Mississippi,24,2473,0,1479,244,1341,5685,,,124,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Montana,30,2486,0,1272,186,899,4934,,,61,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,North Carolina,158,11717,0,6439,1070,5568,25278,,,326,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,North Dakota,11,826,0,449,65,330,1730,,,49,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Nebraska,32,1892,0,1080,240,806,4129,,,79,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,New Hampshire,53,2726,0,1651,280,1564,6391,,,117,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,New Jersey,220,6678,0,3475,742,3263,14655,,,277,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,New Mexico,28,3654,0,1610,289,1429,7137,,,127,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Nevada,41,5089,0,2042,344,1678,9306,,,112,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,New York,429,13278,0,7291,1424,6329,29247,,,496,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Ohio,343,13826,0,7940,1350,6541,30501,,,501,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Oklahoma,46,5651,0,2758,405,2137,11149,,,152,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Oregon,108,12443,0,5331,742,3842,22806,,,340,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Pennsylvania,292,12033,0,6803,1371,5983,26921,,,439,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Puerto Rico,131,3298,0,1291,191,769,5812,,,132,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Rhode Island,22,947,0,527,99,484,2145,,,66,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,South Carolina,66,5284,0,2960,511,2558,11536,,,157,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,South Dakota,19,1006,0,646,120,528,2353,,,34,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Tennessee,120,10646,0,5671,892,4766,22372,,,277,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Texas,303,30156,0,14452,2439,12098,60161,,,713,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Utah,37,14252,0,3544,321,2280,20553,,,119,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Virginia,189,10580,0,5775,988,5160,22987,,,295,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Virgin Islands,0,132,0,75,11,58,300,,,24,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Vermont,15,1080,0,568,108,538,2365,,,56,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Washington,204,20866,0,8767,1206,6092,37631,,,496,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Wisconsin,101,5437,0,3468,606,2762,12586,,,212,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,West Virginia,44,3541,0,1577,216,1368,6820,,,74,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Wyoming,11,1150,0,714,113,516,2540,,,36,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,Other*,0,0,0,0,0,0,40,,,40,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php
2024-09-20,TOTAL,6427,423499,0,202268,34763,166347,845585,,,12281,,,,,AE7Q,https://www.ae7q.com/query/stat/LicenseUSA.php

Can't render this file because it is too large.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 212 KiB

After

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 633 KiB

After

Width:  |  Height:  |  Size: 645 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 609 KiB

After

Width:  |  Height:  |  Size: 615 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 179 KiB

After

Width:  |  Height:  |  Size: 178 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 142 KiB

After

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 183 KiB

After

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 175 KiB

After

Width:  |  Height:  |  Size: 176 KiB