Skip to content

Commit

Permalink
fix #589; allow for recoding for 2023 PUMS
Browse files Browse the repository at this point in the history
  • Loading branch information
walkerke committed Oct 17, 2024
1 parent 45f84bf commit fe702c7
Show file tree
Hide file tree
Showing 6 changed files with 6,007 additions and 7 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Authors@R: c(
person(given = "Kyle", family = "Walker", email="[email protected]", role=c("aut", "cre")),
person(given = "Matt", family = "Herman", email = "[email protected]", role = "aut"),
person(given = "Kris", family = "Eberwein", email = "[email protected]", role = "ctb"))
Date: 2024-10-13
Date: 2024-10-17
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
16 changes: 12 additions & 4 deletions R/load_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ load_data_pums <- function(variables, state, puma, key, year, survey,

# for which years is data dictionary available in pums_variables?
# we'll use this a couple times later on
recode_years <- 2017:2022
recode_years <- 2017:2023

base <- sprintf("https://api.census.gov/data/%s/acs/%s/pums",
year, survey)
Expand Down Expand Up @@ -846,7 +846,11 @@ load_data_pums <- function(variables, state, puma, key, year, survey,

# If geo is NULL, state should be added back in here
if (is.null(geo)) {
vars_to_get <- paste0(vars_to_get, ",ST")
if (year > 2022) {
vars_to_get <- paste0(vars_to_get, ",STATE")
} else {
vars_to_get <- paste0(vars_to_get, ",ST")
}
}

query <- list(get = vars_to_get,
Expand Down Expand Up @@ -1022,7 +1026,7 @@ load_data_pums_vacant <- function(variables, state, puma, key, year, survey,

# for which years is data dictionary available in pums_variables?
# we'll use this a couple times later on
recode_years <- 2017:2022
recode_years <- 2017:2023

base <- sprintf("https://api.census.gov/data/%s/acs/%s/pums",
year, survey)
Expand Down Expand Up @@ -1096,7 +1100,11 @@ load_data_pums_vacant <- function(variables, state, puma, key, year, survey,

# If geo is NULL, state should be added back in here
if (is.null(geo)) {
vars_to_get <- paste0(vars_to_get, ",ST")
if (year > 2022) {
vars_to_get <- paste0(vars_to_get, ",STATE")
} else {
vars_to_get <- paste0(vars_to_get, ",ST")
}
}

# Combine the default query with the variables filter query
Expand Down
8 changes: 7 additions & 1 deletion R/pums.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,13 @@ get_pums <- function(variables = NULL,
# }
# }

join_vars <- c("SERIALNO", "SPORDER", "WGTP", "PWGTP", "ST")
# As of 2023, `ST` is renamed to `STATE`
if (year < 2023) {
join_vars <- c("SERIALNO", "SPORDER", "WGTP", "PWGTP", "ST")
} else {
join_vars <- c("SERIALNO", "SPORDER", "WGTP", "PWGTP", "STATE")
}


variables <- variables[!variables %in% join_vars]

Expand Down
Loading

0 comments on commit fe702c7

Please sign in to comment.