Skip to content

Commit

Permalink
Merge pull request #522 from walkerke/dhc-update
Browse files Browse the repository at this point in the history
Update `get_decennial()` to support the new DHC and DP summary files
  • Loading branch information
walkerke committed May 25, 2023
2 parents 7ba55d9 + a692ed1 commit 7a643d0
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 28 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.3.4
Version: 1.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-05-19
Date: 2023-05-25
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
20 changes: 10 additions & 10 deletions R/census.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
#' Defaults to FALSE; if TRUE, only needs to be called once per
#' dataset. If variables dataset is already cached via the
#' \code{load_variables} function, this can be bypassed.
#' @param year The year for which you are requesting data. Defaults to 2010; 2000,
#' @param year The year for which you are requesting data. Defaults to 2020; 2000,
#' 2010, and 2020 are available.
#' @param sumfile The Census summary file; defaults to \code{"sf1"} but will switch to \code{"pl"} if the year supplied is 2020. Not all summary files are available for each decennial Census year.
#' @param sumfile The Census summary file; defaults to \code{"dhc"}. Not all summary files are available for each decennial Census year.
#' @param state The state for which you are requesting data. State
#' names, postal codes, and FIPS codes are accepted.
#' Defaults to NULL.
Expand All @@ -22,8 +22,7 @@
#' to `state`. Defaults to NULL.
#' @param geometry if FALSE (the default), return a regular tibble of ACS data.
#' if TRUE, uses the tigris package to return an sf tibble
#' with simple feature geometry in the `geometry` column. state, county, tract, and block group are
#' supported for 2000 through 2020; block and ZCTA geometry are supported for 2000 and 2010.
#' with simple feature geometry in the `geometry` column.
#' @param output One of "tidy" (the default) in which each row represents an
#' enumeration unit-variable combination, or "wide" in which each
#' row represents an enumeration unit and the variables are in the
Expand Down Expand Up @@ -69,8 +68,9 @@ get_decennial <- function(geography,
variables = NULL,
table = NULL,
cache_table = FALSE,
year = 2010,
sumfile = c("sf1", "sf2", "sf3", "sf4",
year = 2020,
sumfile = c("pl", "dhc", "dp", "sf1", "sf2",
"sf3", "sf4",
"sf2profile", "sf3profile",
"sf4profile",
"pl", "plnat", "aian",
Expand Down Expand Up @@ -108,7 +108,7 @@ get_decennial <- function(geography,
}

if (year == 2020 && sumfile == "pl" && geography == "public use microdata area") {
stop("PUMAs are not defined yet for the 2020 decennial Census.", call. = FALSE)
stop("PUMAs are not available in the 2020 PL file.", call. = FALSE)
}

if (geography == "voting district" && year != 2020) {
Expand Down Expand Up @@ -157,7 +157,7 @@ get_decennial <- function(geography,
}

if (year == 2020 && sumfile == "pl" && geography == "zip code tabulation area") {
stop("ZCTAs are not currently available for the 2020 decennial Census.", call. = FALSE)
stop("ZCTAs are not available in the 2020 PL file.", call. = FALSE)
}

# if (geography == "zip code tabulation area" && is.null(state)) {
Expand Down Expand Up @@ -424,7 +424,7 @@ get_decennial <- function(geography,
# Give users a heads-up about differential privacy in the 2020 decennial data
# This should print as the final message before data are returned
# For right now, this pertains to the PL file; adjust when new data come out in 2023
if (year == 2020 && sumfile == "pl") {
if (year == 2020) {

msg <- c(crayon::cyan(stringr::str_wrap("Note: 2020 decennial Census data use differential privacy, a technique that introduces errors into data to preserve respondent confidentiality.")),
i = crayon::magenta("Small counts should be interpreted with caution."),
Expand All @@ -442,7 +442,7 @@ get_decennial <- function(geography,
# Give users a heads-up about differential privacy in the 2020 decennial data
# This should print as the final message before data are returned
# For right now, this pertains to the PL file; adjust when new data come out in 2023
if (year == 2020 && sumfile == "pl") {
if (year == 2020) {

msg <- c(crayon::cyan(stringr::str_wrap("Note: 2020 decennial Census data use differential privacy, a technique that introduces errors into data to preserve respondent confidentiality.")),
i = crayon::magenta("Small counts should be interpreted with caution."),
Expand Down
6 changes: 3 additions & 3 deletions R/search_variables.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#' or endyear of the decennial Census or ACS sample. 5-year ACS data is
#' available from 2009 through 2020. 1-year ACS data is available from 2005
#' through 2021, with the exception of 2020.
#' @param dataset One of "sf1", "sf2", "sf3", "sf4", "pl",
#' @param dataset One of "sf1", "sf2", "sf3", "sf4", "pl", "dhc", "dp",
#' "as", "gu", "mp", "vi", "acsse", "acs1", "acs3", "acs5", "acs1/profile",
#' "acs3/profile", "acs5/profile", "acs1/subject", "acs3/subject", "acs5/subject",
#' "acs1/cprofile", or "acs5/cprofile".
Expand All @@ -20,7 +20,7 @@
#'
load_variables <- function(
year,
dataset = c("sf1", "sf2", "sf3", "sf4", "pl",
dataset = c("sf1", "sf2", "sf3", "sf4", "pl", "dhc", "dp",
"as", "gu", "mp", "vi", "acsse",
"dpas", "dpgu", "dpmp", "dpvi",
"acs1", "acs3", "acs5", "acs1/profile",
Expand Down Expand Up @@ -73,7 +73,7 @@ load_variables <- function(
}

if (dataset %in% c("sf1", "sf2", "sf3", "sf4", "pl",
"as", "gu", "mp", "vi",
"as", "gu", "mp", "vi", "dhc", "dp",
"dpas", "dpgu", "dpmp", "dpvi")) {
dataset <- paste0("dec/", dataset)
}
Expand Down
15 changes: 7 additions & 8 deletions man/get_decennial.Rd

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

10 changes: 5 additions & 5 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 7a643d0

Please sign in to comment.