Link: https://www.imls.gov/research-evaluation/surveys/public-libraries-survey-pls
library(magrittr)
library(tidyverse)
Link: https://www.imls.gov/research-evaluation/surveys/public-libraries-survey-pls
library(magrittr)
library(tidyverse)
# [Website](https://hudgis-hud.opendata.arcgis.com/datasets/zip-code-population-weighted-centroids-1/about) | |
# [API](https://hudgis-hud.opendata.arcgis.com/datasets/zip-code-population-weighted-centroids-1/api) | |
library(magrittr) | |
library(dplyr) | |
library(jsonlite) | |
# All zip codes, all columns | |
url <- "https://services.arcgis.com/VTyQ9soqVukalItT/arcgis/rest/services/ZIP_Code_Population_Weighted_Centroids/FeatureServer/0/query?where=1%3D1&outFields=*&outSR=4326&f=json" | |
centroids <- fromJSON(url)$features | |
# Oregon zip codes, essential columns only |
getCMS <- function(datasetID, | |
columns = "*", | |
where = NULL, | |
limit = 0, | |
root = "https://data.cms.gov/provider-data/api/1/datastore/sql") | |
{ | |
require(magrittr) | |
require(httr) | |
require(jsonlite) | |
url <- sprintf("https://data.cms.gov/provider-data/api/1/metastore/schemas/dataset/items/%s?show-reference-ids", datasetID) |
pal <- c("#064276", # OHA Blue | |
"#EC5A24", # OHA Orange | |
"#009F98", # Sea Glass | |
"#752E71", # Beauty Berry | |
"#FCB53B", # Oregon Sunshine | |
"#D6DBE9", # OHA Blue (background tint) | |
"#E6F0EF", # Sea Glass (background tint) | |
"#E9E1E8", # Beauty Berry (background tint) | |
"#FFF1DC", # Oregon Sunshine (background tint) | |
"#BC4010", # OHA Orange (dark) |
# US Census ACS 5-year API documentation: https://www.census.gov/data/developers/data-sets/acs-5year.html | |
# tidycensus documentation: https://walker-data.com/tidycensus/ | |
Sys.getenv("CENSUS_API_KEY") # load pre-installed Census API key | |
getACSbyZCTA <- function(lookup, table = NULL, variables = NULL, dataset = "acs5/profile", year = 2023) { | |
require(magrittr) | |
require(dplyr) | |
require(tidyr) | |
require(tidycensus) |
search <- function(file, str) { | |
text <- readLines(file.path(path, file), warn = FALSE) | |
df <- data.frame(file = file, | |
line = 1:length(text), | |
regex = str, | |
result = grepl(str, text), | |
text) | |
df[df$result == TRUE, ] | |
} |
# Reference: https://www.bls.gov/developers/api_r.htm | |
library(magrittr) | |
library(dplyr) | |
library(devtools) | |
install_github("mikeasilva/blsAPI") # https://github.com/mikeasilva/blsAPI | |
library(rjson) | |
library(blsAPI) | |
payload <- list("seriesid" = c("CUUR0000SA0L1E"), | |
"startyear" = 2016, |
c(rgb( 26, 26, 26, maxColorValue = 255), | |
rgb( 51, 51, 51, maxColorValue = 255), | |
rgb( 77, 77, 77, maxColorValue = 255), | |
rgb(102, 102, 102, maxColorValue = 255), | |
rgb(127, 127, 127, maxColorValue = 255), | |
rgb(153, 153, 153, maxColorValue = 255), | |
rgb(179, 179, 179, maxColorValue = 255), | |
rgb(204, 204, 204, maxColorValue = 255), | |
rgb(230, 230, 230, maxColorValue = 255)) |
library(magrittr) | |
library(dplyr) | |
c("Alice", | |
"Bob", | |
"Carol", | |
"Dave") %>% | |
unique() %>% | |
sample(1e6, replace = TRUE) %>% | |
data.frame(names = .) %>% |
library(magrittr) | |
library(readr) | |
library(tidyr) | |
library(censusapi) | |
name <- "acs/acs5" # See https://api.census.gov/data.html for list of tables for the name argument for listCensusMetadata() | |
vintage <- 2012 | |
metadata <- | |
listCensusMetadata(name = name, vintage = vintage) %>% |