diff --git a/DESCRIPTION b/DESCRIPTION index 7f2d051..fcc889c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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.6.3 +Version: 1.6.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: 2024-03-20 +Date: 2024-05-16 URL: https://walker-data.com/tidycensus/ BugReports: https://github.com/walkerke/tidycensus/issues Description: An integrated R interface to several United States Census Bureau @@ -41,4 +41,4 @@ Suggests: survey, srvyr, terra -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 diff --git a/R/estimates.R b/R/estimates.R index b41a0a0..bc95806 100644 --- a/R/estimates.R +++ b/R/estimates.R @@ -104,12 +104,12 @@ get_estimates <- function(geography = c("us", "region", "division", "state", "co } if (vintage > 2022) { - rlang::abort("The Characteristics dataset has not yet been released for vintages beyond 2022.") + rlang::abort("The Characteristics dataset has not yet been released for vintages beyond 2022") } if (geography == "state") { - state_raw <- suppressMessages(readr::read_csv("https://www2.census.gov/programs-surveys/popest/datasets/2020-2022/state/asrh/sc-est2022-alldata6.csv")) + state_raw <- suppressMessages(readr::read_csv(sprintf("https://www2.census.gov/programs-surveys/popest/datasets/2020-%s/state/asrh/sc-est%s-alldata6.csv", vintage, vintage))) if (!is.null(state)) { state <- validate_state(state) @@ -125,7 +125,7 @@ get_estimates <- function(geography = c("us", "region", "division", "state", "co NAME:SEX, HISP = ORIGIN, RACE:AGE, - POPESTIMATE2020:POPESTIMATE2022) %>% + dplyr::contains("POPESTIMATE")) %>% dplyr::mutate(AGEGROUP = dplyr::case_when( AGE %in% 0:4 ~ 1, AGE %in% 5:9 ~ 2, @@ -147,7 +147,7 @@ get_estimates <- function(geography = c("us", "region", "division", "state", "co AGE == 85 ~ 18 )) %>% tidyr::pivot_longer( - POPESTIMATE2020:POPESTIMATE2022, + dplyr::contains("POPESTIMATE"), names_to = "year", values_to = "value", names_prefix = "POPESTIMATE" @@ -156,6 +156,10 @@ get_estimates <- function(geography = c("us", "region", "division", "state", "co } else if (geography == "county") { + if (vintage > 2022) { + rlang::abort("The county characteristics dataset for this vintage has not yet been released.") + } + if (!is.null(state)) { state <- validate_state(state) @@ -482,11 +486,11 @@ get_estimates <- function(geography = c("us", "region", "division", "state", "co } else if (geography == "place") { - if (vintage > 2022) { - rlang::abort("The most recent PEP release for this geography is 2022.") - } + # if (vintage > 2022) { + # rlang::abort("The most recent PEP release for this geography is 2022.") + # } - raw <- suppressMessages(readr::read_csv("https://www2.census.gov/programs-surveys/popest/datasets/2020-2022/cities/totals/sub-est2022.csv")) %>% + raw <- suppressMessages(readr::read_csv(sprintf("https://www2.census.gov/programs-surveys/popest/datasets/2020-%s/cities/totals/sub-est%s.csv", vintage, vintage))) %>% dplyr::filter(SUMLEV == "162") %>% dplyr::mutate(GEOID = paste0(STATE, PLACE), NAME = paste0(NAME, ", ", STNAME)) diff --git a/man/tidycensus.Rd b/man/tidycensus.Rd index 95c3235..293396e 100644 --- a/man/tidycensus.Rd +++ b/man/tidycensus.Rd @@ -2,10 +2,19 @@ % Please edit documentation in R/tidycensus-package.R \docType{package} \name{tidycensus} +\alias{tidycensus-package} \alias{tidycensus} \title{Return tidy data frames from the US Census Bureau API} \description{ This packages uses US Census Bureau data but is neither endorsed nor supported by the US Census Bureau. +} +\seealso{ +Useful links: +\itemize{ + \item \url{https://walker-data.com/tidycensus/} + \item Report bugs at \url{https://github.com/walkerke/tidycensus/issues} +} + } \author{ Kyle Walker