Last updated: 2022-11-19
Checks: 7 0
Knit directory: myTidyTuesday/
This reproducible R Markdown analysis was created with workflowr (version 1.7.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.
Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.
Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.
The command set.seed(20210907)
was run prior to running
the code in the R Markdown file. Setting a seed ensures that any results
that rely on randomness, e.g. subsampling or permutations, are
reproducible.
Great job! Recording the operating system, R version, and package versions is critical for reproducibility.
Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.
The results in this page were generated with repository version de73731. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.
Note that you need to be careful to ensure that all relevant files for
the analysis have been committed to Git prior to generating the results
(you can use wflow_publish
or
wflow_git_commit
). workflowr only checks the R Markdown
file, but you know if there are other scripts or data files that it
depends on. Below is the status of the Git repository when the results
were generated:
Ignored files:
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: data/.Rhistory
Ignored: data/2022_11_01.png
Ignored: data/2022_11_18.png
Ignored: data/CNHI_Excel_Chart.xlsx
Ignored: data/Chicago.rds
Ignored: data/CommunityTreemap.jpeg
Ignored: data/Community_Roles.jpeg
Ignored: data/ELL.zip
Ignored: data/FM_service_contour_current.zip
Ignored: data/SeriesReport-20220414171148_6c3b18.xlsx
Ignored: data/Weekly_Chicago_IL_Regular_Reformulated_Retail_Gasoline_Prices.csv
Ignored: data/YammerDigitalDataScienceMembership.xlsx
Ignored: data/YammerMemberPage.rds
Ignored: data/YammerMembers.rds
Ignored: data/application_id.feather
Ignored: data/df.rds
Ignored: data/fit_cohesion.rds
Ignored: data/fit_grammar.rds
Ignored: data/fit_phraseology.rds
Ignored: data/fit_syntax.rds
Ignored: data/fit_vocabulary.rds
Ignored: data/grainstocks.rds
Ignored: data/hike_data.rds
Ignored: data/lm_res.rds
Ignored: data/raw_contour.feather
Ignored: data/raw_weather.RData
Ignored: data/sample_submission.csv
Ignored: data/submission.csv
Ignored: data/test.csv
Ignored: data/train.csv
Ignored: data/us_states.rds
Ignored: data/us_states_hexgrid.geojson
Ignored: data/weatherstats_toronto_daily.csv
Untracked files:
Untracked: analysis/2022_09_01_kaggle_tabular_playground.qmd
Untracked: code/YammerReach.R
Untracked: code/autokeras.R
Untracked: code/chicago.R
Untracked: code/glmnet_test.R
Untracked: code/googleCompute.R
Untracked: code/work list batch targets.R
Untracked: environment.yml
Untracked: report.html
Unstaged changes:
Modified: analysis/2021_01_19_tidy_tuesday.Rmd
Modified: analysis/2021_03_24_tidy_tuesday.Rmd
Deleted: analysis/2021_04_20.Rmd
Deleted: analysis/2022_02_11_tabular_playground.Rmd
Deleted: analysis/2022_04_18.qmd
Modified: analysis/EnglishLanguageLearning.Rmd
Modified: analysis/Survival.Rmd
Modified: analysis/_site.yml
Modified: code/_common.R
Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.
These are the previous versions of the repository in which changes were
made to the R Markdown
(analysis/2022_11_18_tidy_tuesday.Rmd
) and HTML
(docs/2022_11_18_tidy_tuesday.html
) files. If you’ve
configured a remote Git repository (see ?wflow_git_remote
),
click on the hyperlinks in the table below to view the files as they
were in that past version.
File | Version | Author | Date | Message |
---|---|---|---|---|
Rmd | de73731 | opus1993 | 2022-11-19 | wflow_publish("analysis/2022_11_18_tidy_tuesday.Rmd") |
The data this week comes from Wikipedia and the Federal Communications Commission, with a credit to Frank Hull for proposing and cleaning the initial dataset.
An example of one of the submissions to Twitter:
tweetrmd::include_tweet("https://twitter.com/NdFest/status/1591803647520018432")
Where is all the Public Radio? This week's #TidyTuesday data looked at radio stations around the United States and their reach. The code can be found here: https://t.co/M85kpXlEO8
— DataFestND (@NdFest) November 13, 2022
And a link for data to reliably link the two TT data sets: https://t.co/QHS2Y6cItR pic.twitter.com/i7G7Y8jvz1
We will start by loading a few R packages into memory:
suppressPackageStartupMessages({
library(tidyverse)
library(sf)
library(tigris)
library(geomtextpath)
})
options(tigris_use_cache = TRUE)
We will load the data as provided by R4DS and use their cleaing script:
tuesdata <- tidytuesdayR::tt_load('2022-11-08')
--- Compiling #TidyTuesday Information for 2022-11-08 ----
--- There are 2 files available ---
--- Starting Download ---
Downloading file 1 of 2: `state_stations.csv`
Downloading file 2 of 2: `station_info.csv`
--- Download complete ---
state_stations <- tuesdata$state_stations |>
right_join(tuesdata$station_info |>
select(-licensee),
by = c("call_sign")) |>
filter(stringr::str_detect(format, 'Public'))
contour_zip_url <- "https://transition.fcc.gov/Bureaus/MB/Databases/fm_service_contour_data/FM_service_contour_current.zip"
contour_zip_file <- here::here("data","FM_service_contour_current.zip")
if (!file.exists(contour_zip_file)) {
download.file(contour_zip_url,
destfile = contour_zip_file)
}
raw_contour_feather <- here::here("data","raw_contour.feather")
if (!file.exists(raw_contour_feather)) {
raw_contour <- read_delim(
contour_zip_file,
delim = "|",
show_col_types = FALSE
) |>
select(-last_col()) |>
set_names(nm = c(
"application_id", "service", "lms_application_id", "dts_site_number", "transmitter_site",
glue::glue("deg_{0:360}")
)) |>
separate(
transmitter_site,
into = c("site_lat", "site_long"),
sep = " ,") |>
pivot_longer(
names_to = "angle",
values_to = "values",
cols = deg_0:deg_360
) |>
mutate(
angle = str_remove(angle, "deg_"),
angle = as.integer(angle)
) |>
separate(
values,
into = c("deg_lat", "deg_lng"),
sep = " ,"
) |>
mutate(
across(c(application_id,
site_lat,
site_long,
deg_lat,
deg_lng),
as.numeric))
arrow::write_feather(raw_contour,
sink = raw_contour_feather)
} else {
raw_contour <- arrow::read_feather(raw_contour_feather,
as_data_frame = TRUE)
}
contour_sf <- raw_contour |>
na.omit() |>
st_as_sf(coords = c("deg_lng", "deg_lat"), crs = 4326) |>
group_by(application_id) |>
slice_tail(n = 360) |>
summarise(geometry = st_combine(geometry)) |>
st_cast("POLYGON")
The following loops through the call letters belonging to the different application IDs so that the two datasets that were provided on Tidy Tuesday can be linked.
As above, we will cache results in a feather file to avoid hitting the fcc web page unnecessarily.
application_id_feather <- here::here("data","application_id.feather")
if (!file.exists(application_id_feather)) {
application_id <- tibble(
application_id = unique(raw_contour$application_id),
call_sign = NA_character_)
site <- "https://licensing.fcc.gov/cgi-bin/ws.exe/prod/cdbs/pubacc/prod/app_det.pl?Application_id="
call_sign_extract <- function(application_id) {
Sys.sleep(sample(10, 1) * 0.02)
paste0(site, application_id) |>
rvest::read_html() |>
rvest::html_nodes("td") %>%
.[[20]] |>
rvest::html_text() |>
stringr::str_replace_all("\n", "") |>
stringr::str_squish()
}
application_id <- application_id |>
mutate(call_sign = map_chr(application_id, call_sign_extract))
arrow::write_feather(application_id,
sink = application_id_feather)
} else {
application_id <- arrow::read_feather(application_id_feather)
}
state_stations |>
inner_join(application_id, by = c("call_sign")) |>
inner_join(contour_sf, by = "application_id")
public_radio <- contour_sf %>%
inner_join(application_id, by = "application_id") |>
inner_join(state_stations, by = "call_sign") |>
shift_geometry()
ggplot() +
geom_sf(data = tigris::states(cb = TRUE) |>
filter(STUSPS %in% c(state.abb,"DC")) |>
shift_geometry(),
color = "gray70",
fill = "gray95") +
geom_sf(data = tigris::metro_divisions(),
color = "gray70",
fill = "orange" ) +
geom_sf(data = public_radio,
fill = NA,
color = "darkblue"
) +
geom_sf_text(data = public_radio ,
aes(label = call_sign),
size = 1.5,
fontface = "bold",
color = "darkblue",
check_overlap = TRUE) +
coord_sf(default_crs = sf::st_crs(public_radio)) +
ggthemes::theme_map() +
theme(plot.title = element_text(hjust = 0.5,
size = 20, face = "bold"),
plot.background = element_rect(fill = "lightblue")) +
labs(title = "Public Radio Station Coverage in the United States",
caption = "DataViz by @jim_gruman | Data from US FCC via Frank Hull | Based on TorvicialND @NdFest submission")
Retrieving data for the year 2020
Retrieving data for the year 2020
|
| | 0%
|
|= | 1%
|
|= | 2%
|
|== | 3%
|
|=== | 4%
|
|==== | 5%
|
|==== | 6%
|
|===== | 7%
|
|===== | 8%
|
|====== | 8%
|
|====== | 9%
|
|======= | 9%
|
|======= | 10%
|
|======== | 11%
|
|======== | 12%
|
|========= | 13%
|
|========== | 14%
|
|========== | 15%
|
|=========== | 15%
|
|=========== | 16%
|
|============ | 17%
|
|============ | 18%
|
|============= | 19%
|
|============== | 20%
|
|=============== | 21%
|
|================ | 22%
|
|================ | 23%
|
|================= | 24%
|
|================== | 25%
|
|================== | 26%
|
|=================== | 27%
|
|=================== | 28%
|
|==================== | 28%
|
|==================== | 29%
|
|===================== | 30%
|
|====================== | 31%
|
|====================== | 32%
|
|======================= | 32%
|
|======================= | 33%
|
|======================== | 34%
|
|======================== | 35%
|
|========================= | 36%
|
|========================== | 37%
|
|=========================== | 39%
|
|============================ | 39%
|
|============================ | 40%
|
|============================ | 41%
|
|============================= | 41%
|
|============================= | 42%
|
|============================== | 42%
|
|============================== | 43%
|
|=============================== | 44%
|
|=============================== | 45%
|
|================================ | 46%
|
|================================= | 47%
|
|================================== | 48%
|
|================================== | 49%
|
|=================================== | 50%
|
|==================================== | 51%
|
|==================================== | 52%
|
|===================================== | 53%
|
|====================================== | 54%
|
|======================================= | 56%
|
|======================================== | 57%
|
|========================================= | 58%
|
|========================================= | 59%
|
|========================================== | 60%
|
|=========================================== | 61%
|
|=========================================== | 62%
|
|============================================ | 63%
|
|============================================= | 64%
|
|============================================= | 65%
|
|============================================== | 65%
|
|============================================== | 66%
|
|=============================================== | 67%
|
|=============================================== | 68%
|
|================================================ | 69%
|
|================================================= | 70%
|
|================================================== | 71%
|
|=================================================== | 72%
|
|=================================================== | 73%
|
|=================================================== | 74%
|
|==================================================== | 74%
|
|===================================================== | 75%
|
|===================================================== | 76%
|
|====================================================== | 78%
|
|======================================================= | 78%
|
|======================================================= | 79%
|
|======================================================== | 80%
|
|========================================================= | 81%
|
|========================================================== | 82%
|
|========================================================== | 83%
|
|=========================================================== | 84%
|
|=========================================================== | 85%
|
|============================================================ | 86%
|
|============================================================= | 87%
|
|============================================================== | 88%
|
|============================================================== | 89%
|
|=============================================================== | 89%
|
|=============================================================== | 90%
|
|=============================================================== | 91%
|
|================================================================ | 91%
|
|================================================================= | 92%
|
|================================================================= | 93%
|
|================================================================== | 94%
|
|================================================================== | 95%
|
|=================================================================== | 95%
|
|=================================================================== | 96%
|
|==================================================================== | 97%
|
|===================================================================== | 98%
|
|===================================================================== | 99%
|
|======================================================================| 100%
Let’s tweet the result
ggsave(here::here("data","2022_11_18.png"),
width = 6, height = 5, dpi = 300, bg = "black",
device = "png")
tweetrmd::include_tweet("https://twitter.com/NdFest/status/1591803647520018432")
Where is all the Public Radio? This week's #TidyTuesday data looked at radio stations around the United States and their reach. The code can be found here: https://t.co/M85kpXlEO8
— DataFestND (@NdFest) November 13, 2022
And a link for data to reliably link the two TT data sets: https://t.co/QHS2Y6cItR pic.twitter.com/i7G7Y8jvz1
sessionInfo()
R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22621)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.utf8
[2] LC_CTYPE=English_United States.utf8
[3] LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] geomtextpath_0.1.1 tigris_1.6.1 sf_1.0-8 forcats_0.5.2
[5] stringr_1.4.1 dplyr_1.0.10 purrr_0.3.5 readr_2.1.3
[9] tidyr_1.2.1 tibble_3.1.8 ggplot2_3.4.0 tidyverse_1.3.2
[13] workflowr_1.7.0
loaded via a namespace (and not attached):
[1] googledrive_2.0.0 colorspace_2.0-3 selectr_0.4-2
[4] ellipsis_0.3.2 class_7.3-20 rgdal_1.5-32
[7] rprojroot_2.0.3 fs_1.5.2 rstudioapi_0.14
[10] proxy_0.4-27 farver_2.1.1 bit64_4.0.5
[13] fansi_1.0.3 lubridate_1.9.0 xml2_1.3.3
[16] cachem_1.0.6 knitr_1.40 jsonlite_1.8.3
[19] broom_1.0.1 dbplyr_2.2.1 compiler_4.2.2
[22] httr_1.4.4 backports_1.4.1 assertthat_0.2.1
[25] fastmap_1.1.0 gargle_1.2.1 cli_3.4.1
[28] later_1.3.0 s2_1.1.0 htmltools_0.5.3
[31] tools_4.2.2 gtable_0.3.1 glue_1.6.2
[34] wk_0.7.0 ggthemes_4.2.4 rappdirs_0.3.3
[37] Rcpp_1.0.9 cellranger_1.1.0 jquerylib_0.1.4
[40] vctrs_0.5.0 xfun_0.34 ps_1.7.2
[43] rvest_1.0.3 timechange_0.1.1 lifecycle_1.0.3
[46] googlesheets4_1.0.1 getPass_0.2-2 scales_1.2.1
[49] vroom_1.6.0 hms_1.1.2 promises_1.2.0.1
[52] parallel_4.2.2 yaml_2.3.6 curl_4.3.3
[55] sass_0.4.2 tweetrmd_0.0.9 stringi_1.7.8
[58] highr_0.9 maptools_1.1-5 e1071_1.7-12
[61] rlang_1.0.6 pkgconfig_2.0.3 systemfonts_1.0.4
[64] evaluate_0.18 lattice_0.20-45 bit_4.0.4
[67] processx_3.8.0 tidyselect_1.2.0 here_1.0.1
[70] magrittr_2.0.3 tidytuesdayR_1.0.2 R6_2.5.1
[73] generics_0.1.3 DBI_1.1.3 pillar_1.8.1
[76] haven_2.5.1 whisker_0.4 foreign_0.8-83
[79] withr_2.5.0 units_0.8-0 sp_1.5-1
[82] modelr_0.1.9 crayon_1.5.2 uuid_1.1-0
[85] KernSmooth_2.23-20 utf8_1.2.2 tzdb_0.3.0
[88] rmarkdown_2.17 usethis_2.1.6 grid_4.2.2
[91] readxl_1.4.1 callr_3.7.3 git2r_0.30.1
[94] reprex_2.0.2 digest_0.6.30 classInt_0.4-8
[97] httpuv_1.6.6 arrow_10.0.0 textshaping_0.3.6
[100] munsell_0.5.0 bslib_0.4.1