-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split rendering code for counties and places and update .gitignore
- Loading branch information
1 parent
9dde021
commit a2fd769
Showing
278 changed files
with
21,834 additions
and
134,667 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#Code to create data for standard factsheets for places | ||
|
||
#Gabe Morrison | ||
|
||
#2023-03-15 | ||
|
||
library(tidyverse) | ||
library(tidycensus) | ||
|
||
if(!file.exists("data/998_all-places.Rda")) { | ||
|
||
place_geoids <- read_csv(here("mobility-metrics", "place-populations.csv")) %>% | ||
filter(year == 2020) | ||
|
||
prepped_places <- place_geoids %>% | ||
mutate(GEOID = paste0(state, place)) %>% | ||
select(geoid = GEOID) %>% | ||
mutate(state_title = list(state_title = FALSE), | ||
geoid = str_c(geoid, ";"), | ||
geoid = strsplit(geoid, ";") | ||
) | ||
|
||
geoid_lst <- as.list(prepped_places$geoid) | ||
|
||
prepped_places <- tibble(filename = "index.html", | ||
params = map(geoid_lst, | ||
~list(state_place = ., | ||
state_title = FALSE) | ||
), | ||
dir_name = str_c("factsheets/998_place-pages/", geoid_lst, "/") | ||
) | ||
|
||
save(prepped_places, file = "data/998_all-places.Rda") | ||
|
||
} else { | ||
|
||
load("data/998_all-places.Rda") | ||
|
||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
load_place_data <- function() { | ||
|
||
my_col_type <- cols( | ||
state = col_character(), | ||
county = col_character() | ||
) | ||
|
||
county_names <- read_csv(here("mobility-metrics", "old", "01_mobility-metrics.csv")) %>% | ||
select(state, county, state_name, county_name) %>% | ||
distinct() | ||
|
||
data_recent <- read_csv( | ||
here("mobility-metrics", "00_mobility-metrics_recent.csv"), | ||
col_type = | ||
cols( | ||
state = col_character(), | ||
county = col_character(), | ||
ratio_black_nh_house_value_households = col_character(), | ||
ratio_hispanic_house_value_households = col_character(), | ||
ratio_other_nh_house_value_households = col_character(), | ||
ratio_white_nh_house_value_households = col_character(), | ||
ratio_population_pc_physician = col_character(), | ||
.default = col_double() | ||
) | ||
) %>% | ||
left_join(county_names, by = c("state", "county")) %>% | ||
prep_data() | ||
|
||
data_years <- read_csv( | ||
here("mobility-metrics","00_mobility-metrics_longitudinal.csv"), | ||
col_type = cols( | ||
state = col_character(), | ||
county = col_character(), | ||
ratio_black_nh_house_value_households = col_character(), | ||
ratio_hispanic_house_value_households = col_character(), | ||
ratio_other_nh_house_value_households = col_character(), | ||
ratio_white_nh_house_value_households = col_character(), | ||
ratio_population_pc_physician = col_character(), | ||
.default = col_double() | ||
) | ||
) %>% | ||
left_join(county_names, by = c("state", "county")) %>% | ||
prep_data() | ||
|
||
data_race_ethnicity <- read_csv( | ||
here("mobility-metrics", "01_mobility-metrics_race-ethnicity_recent.csv"), | ||
col_types = my_col_type | ||
) %>% | ||
left_join(county_names, by = c("state", "county")) %>% | ||
prep_data() | ||
|
||
data_race <- read_csv( | ||
here("mobility-metrics", "02_mobility-metrics_race_recent.csv"), | ||
col_types = my_col_type | ||
) %>% | ||
left_join(county_names, by = c("state", "county")) %>% | ||
prep_data() | ||
|
||
data_race_share <- read_csv( | ||
here("mobility-metrics", "03_mobility-metrics_race-share_recent.csv"), | ||
col_types = my_col_type | ||
) %>% | ||
left_join(county_names, by = c("state", "county")) %>% | ||
prep_data() | ||
|
||
data_list <- list( | ||
recent = data_recent, | ||
years = data_years, | ||
race_ethnicity = data_race_ethnicity, | ||
race = data_race, | ||
race_share = data_race_share | ||
) | ||
|
||
return(data_list) | ||
|
||
} |
This file contains 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
This file contains 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
This file contains 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
Binary file not shown.
This file contains 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
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.