Skip to content

Commit

Permalink
support island areas DHC files
Browse files Browse the repository at this point in the history
  • Loading branch information
walkerke committed Jul 24, 2023
1 parent df0183b commit c899a33
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 11 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Package: tidycensus
Type: Package
Title: Load US Census Boundary and Attribute Data as 'tidyverse' and 'sf'-Ready Data Frames
Version: 1.4.3
Version: 1.4.4
Authors@R: c(
person(given = "Kyle", family = "Walker", email="kyle@walker-data.com", role=c("aut", "cre")),
person(given = "Matt", family = "Herman", email = "mfherman@gmail.com", role = "aut"),
person(given = "Kris", family = "Eberwein", email = "eberwein@knights.ucf.edu", role = "ctb"))
Date: 2023-07-11
Date: 2023-07-24
URL: https://walker-data.com/tidycensus/
BugReports: https://github.com/walkerke/tidycensus/issues
Description: An integrated R interface to several United States Census Bureau
Expand Down
12 changes: 9 additions & 3 deletions R/estimates.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,14 @@ get_estimates <- function(geography = c("us", "region", "division", "state", "co

if (!is.null(state)) {
state <- validate_state(state)

county_raw <- suppressMessages(readr::read_csv(sprintf("https://www2.census.gov/programs-surveys/popest/datasets/2020-2022/counties/asrh/cc-est2022-alldata-%s.csv", state)))

} else {
county_raw <- suppressMessages(readr::read_csv("https://www2.census.gov/programs-surveys/popest/datasets/2020-2022/counties/asrh/cc-est2022-all.csv"))
}

county_raw <- suppressMessages(readr::read_csv(sprintf("https://www2.census.gov/programs-surveys/popest/datasets/2020-2022/counties/asrh/cc-est2022-alldata-%s.csv", state)))


if (!is.null(county)) {
county <- purrr::map_chr(county, function(x) {
Expand Down Expand Up @@ -198,10 +203,11 @@ get_estimates <- function(geography = c("us", "region", "division", "state", "co
SEX == "MALE" ~ 1L,
SEX == "FEMALE" ~ 2L
),
GEOID = paste0(STATE, COUNTY)
GEOID = paste0(STATE, COUNTY),
NAME = paste0(CTYNAME, ", ", STNAME)
) %>%
dplyr::rename(AGEGROUP = AGEGRP) %>%
dplyr::select(GEOID, NAME = CTYNAME,
dplyr::select(GEOID, NAME,
YEAR:value) %>%
dplyr::rename(year = YEAR) %>%
dplyr::filter(year != 1) %>%
Expand Down
3 changes: 2 additions & 1 deletion R/helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,8 @@ summary_files <- function(year) {
"cd115", "cd115profile", "cd116")
} else if (year == 2020) {
sumfiles <- c("pl", "dhc", "dp", "pes", "dpas",
"dpmp", "dpgu", "dpvi")
"dpmp", "dpgu", "dpvi",
"dhcvi", "dhcgu", "dhcvi", "dhcas")
} else {
stop("Invalid year for `get_decennial()`; valid years are 2000, 2010, and 2020.", call. = FALSE)
}
Expand Down
4 changes: 3 additions & 1 deletion R/search_variables.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ load_variables <- function(
dataset = c("sf1", "sf2", "sf3", "sf4", "pl", "dhc", "dp",
"as", "gu", "mp", "vi", "acsse",
"dpas", "dpgu", "dpmp", "dpvi",
"dhcvi", "dhcgu", "dhcvi", "dhcas",
"acs1", "acs3", "acs5", "acs1/profile",
"acs3/profile", "acs5/profile", "acs1/subject", "acs3/subject",
"acs5/subject", "acs1/cprofile", "acs5/cprofile"),
Expand Down Expand Up @@ -74,7 +75,8 @@ load_variables <- function(

if (dataset %in% c("sf1", "sf2", "sf3", "sf4", "pl",
"as", "gu", "mp", "vi", "dhc", "dp",
"dpas", "dpgu", "dpmp", "dpvi")) {
"dpas", "dpgu", "dpmp", "dpvi",
"dhcvi", "dhcgu", "dhcvi", "dhcas")) {
dataset <- paste0("dec/", dataset)
}

Expand Down
4 changes: 3 additions & 1 deletion R/zzz.r
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ utils::globalVariables(c("variable", "value", "GEOID", "NAME", "type", "moe",
"level", "tidycensus_weight_total", "weight_coef", "SUMLEV",
"REGION", "DIVISION", "CTYNAME", "STNAME", "ALAND", "AWATER",
"COUNTYFP", "COUNTYNS", "LSAD", "NAMELSAD", "STATEFP", "geometry",
"CBSA", "CSA", "PLACE", "ZCTA", "ZCTA5CE00"))
"CBSA", "CSA", "PLACE", "ZCTA", "ZCTA5CE00", "AGE", "AGEGROUP", "AGEGRP",
"HISP", "HNAC_FEMALE", "ORIGIN", "POPESTIMATE2020",
"POPESTIMATE2022", "RACE", "SEX", "TOT_POP", "YEAR", "category"))

#' @importFrom rlang .data
NULL
Expand Down
6 changes: 3 additions & 3 deletions man/load_variables.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c899a33

Please sign in to comment.