This file contains hidden or 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
library(tidyverse) | |
library(tidycensus) | |
library(jsonlite) | |
# get all available census api endpoints | |
census_api_discovery <- fromJSON("https://api.census.gov/data.json") | |
# parse responses into df with vintage and dataset name | |
api_name_vintage <- tibble( | |
vintage = census_api_discovery$dataset$c_vintage, |
This file contains hidden or 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
library(tidyverse) | |
library(lubridate) | |
library(janitor) | |
# get urls of csv incident files to download for year 2015 - 2022 | |
urls <- map_chr(2015:2022, ~ paste0("https://police-static.cityofomaha.org/crime-data/", | |
.x, "/Incidents_", .x, ".csv")) | |
# download all years, combine into one df and clean up variable names | |
incidents <- read_csv(urls) |> |
This file contains hidden or 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
library(tidyverse) | |
df <- tribble( | |
~agency, ~offense, ~type, ~date, | |
"Agency A", "Drug", "sentence_dt", as.Date("2016-01-04"), | |
"Agency A", "Person", "sentence_dt", as.Date("2017-07-01"), | |
"Agency A", "Drug", "start_dt", as.Date("2016-04-04"), | |
"Agency A", "Drug", "end_dt", as.Date("2018-12-09"), | |
"Agency B", "Person", "sentence_dt", as.Date("2017-01-30"), | |
"Agency B", "Person", "start_dt", as.Date("2017-01-30"), |
This file contains hidden or 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
library(tidyverse) | |
df <- tribble( | |
~agency, ~offense, ~type, ~date, | |
"Agency A", "Drug", "sentence_dt", as.Date("2016-01-04"), | |
"Agency A", "Person", "sentence_dt", as.Date("2017-07-01"), | |
"Agency A", "Drug", "start_dt", as.Date("2016-04-04"), | |
"Agency A", "Drug", "end_dt", as.Date("2018-12-09"), | |
"Agency B", "Person", "sentence_dt", as.Date("2017-01-30"), | |
"Agency B", "Person", "start_dt", as.Date("2017-01-30"), |
This file contains hidden or 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
library(tidycensus) | |
library(tidyverse) | |
state <- get_decennial( | |
geography = "state", | |
variables = "P001001", | |
state = "CA" | |
) | |
tract <- get_decennial( |
This file contains hidden or 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
## Estimate race and ethnicity of health care workers by PUMA | |
# NOTE: this requires the github version of tidycensus | |
# remotes::install_github("walkerke/tidycensus") | |
library(tidycensus) | |
library(tidyverse) | |
# get industry and race vars from census api | |
ind_pums <- get_pums( | |
variables = c("PUMA", "INDP", "RAC1P", "HISP"), |
This file contains hidden or 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
library(tidyverse) | |
library(tidycensus) | |
library(sf) | |
library(tmap) | |
options(tigris_use_cache = TRUE) | |
sro <- read_csv("https://github.com/mfherman/r-study-group/raw/master/nyc_sro.csv") | |
sro_sf <- sro %>% |