-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprep-data.R
60 lines (36 loc) · 1.42 KB
/
prep-data.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# prep-data.R
library(tidyverse)
library(sf)
library(urbnmapr)
tn_test <- read_dta("raw-data/TN_test.dta") # lightcast/jobs posting data
tn_test
counties_sf <- get_urbn_map("counties", sf = TRUE)
write_rds(counties_sf, "counties_sf.rds")
counties_sf <- read_rds("counties_sf.rds")
tn_test <- tn_test %>%
rename(county_fips = countyfips) %>%
select(county_fips, unique_postings = uniquepostingsfromjan2010)
counties_sf <- counties_sf %>%
left_join(tn_test)
# can probably ignore these
# Sys.setenv(PATH = paste("/opt/homebrew/bin", Sys.getenv("PATH"), sep = ":"))
# Sys.setenv(PROJ_LIB = "/opt/homebrew/Cellar/proj/9.4.1/share/proj")
# Sys.setenv(GDAL_CONFIG = "/opt/homebrew/bin/gdal-config")
counties_sf <- st_transform(counties_sf, crs = 4326)
counties_sf <- counties_sf %>%
as_mapbox_source()
counties_sf %>% write_rds("counties_sf_processed.rds")
source("token.R")
ipeds_green <- read_dta("raw-data/ipeds&green.dta")
ipeds_green_summed <- ipeds_green %>%
group_by(unitid, greencat) %>%
summarize(sum_cmplt_green = sum(cmplt_tot)) %>%
filter(greencat != "") %>%
spread(greencat, sum_cmplt_green)
ipeds_green_summed <- ipeds_green_summed %>%
pivot_longer(-unitid, names_to = "greencat", values_to = "size")
write_rds(ipeds_green_summed, "ipeds_green_summed.rds")
hdallyears <- read_dta("raw-data/hdallyears.dta")
hdallyears <- hdallyears %>%
filter(year == 2020)
write_rds(hdallyears, "hdallyears.rds")