Skip to content

Commit

Permalink
fixing default year
Browse files Browse the repository at this point in the history
  • Loading branch information
mdblocker committed Jun 12, 2023
1 parent 373eb4e commit 188da97
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions R/get_census_api_2.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#' It is used by the \code{get_census_api} function. The user should not need to call this
#' function directly.
#'
#' @param data_url URL root of the API, including the question mark,
#' e.g., \code{"api.census.gov/data/2020/dec/dhc"}.
#' @param data_url URL root of the API,
#' e.g., \code{"https://api.census.gov/data/2020/dec/dhc"}.
#' @param key A required character object containing user's Census API key,
#' which can be requested \href{https://api.census.gov/data/key_signup.html}{here}.
#' @param get A character vector of variables to get,
Expand Down
4 changes: 2 additions & 2 deletions R/merge_surnames.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#' named 'surname' containing list of surnames to be merged with Census lists.
#' @param surname.year An object of class \code{numeric} indicating which year
#' Census Surname List is from. Accepted values are \code{2010} and \code{2000}.
#' Default is \code{2010}.
#' Default is \code{2020}.
#' @param name.data An object of class \code{data.frame}. Must contain a leading
#' column of surnames, and 5 subsequent columns, with Pr(Race | Surname) for each
#' of the five major racial categories.
Expand All @@ -54,7 +54,7 @@
#'
#' @keywords internal

merge_surnames <- function(voter.file, surname.year = 2010, name.data, clean.surname = TRUE, impute.missing = TRUE) {
merge_surnames <- function(voter.file, surname.year = 2020, name.data, clean.surname = TRUE, impute.missing = TRUE) {

if ("surname" %in% names(voter.file) == FALSE) {
stop('Data does not contain surname field.')
Expand Down
4 changes: 2 additions & 2 deletions R/predict_race.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
#' If \code{TRUE}, \code{\var{voter.file}} should include a numerical variable \code{\var{sex}},
#' where \code{\var{sex}} is coded as 0 for males and 1 for females.
#' @param year An optional character vector specifying the year of U.S. Census geographic
#' data to be downloaded. Use \code{"2010"}, or \code{"2020"}. Default is \code{"2010"}.
#' data to be downloaded. Use \code{"2010"}, or \code{"2020"}. Default is \code{"2020"}.
#' @param party An optional character object specifying party registration field
#' in \code{\var{voter.file}}, e.g., \code{\var{party} = "PartyReg"}.
#' If specified, race/ethnicity predictions will be conditioned
Expand Down Expand Up @@ -136,7 +136,7 @@
#' @export

predict_race <- function(voter.file, census.surname = TRUE, surname.only = FALSE,
surname.year = 2010, census.geo, census.key = NULL, census.data = NULL, age = FALSE,
surname.year = 2020, census.geo, census.key = NULL, census.data = NULL, age = FALSE,
sex = FALSE, year = "2020", party = NULL, retry = 3, impute.missing = TRUE,
use.counties = FALSE, model = "BISG", race.init = NULL, name.dictionaries = NULL,
names.to.use = "surname", control = NULL) {
Expand Down
6 changes: 3 additions & 3 deletions R/race_prediction_funs.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ NULL
#' @keywords internal

.predict_race_old <- function(voter.file,
census.surname = TRUE, surname.only = FALSE, surname.year = 2010, name.dictionaries = NULL,
census.surname = TRUE, surname.only = FALSE, surname.year = 2020, name.dictionaries = NULL,
census.geo, census.key, census.data = NULL, age = FALSE, sex = FALSE, year = "2020",
party, retry = 3, impute.missing = TRUE, use.counties = FALSE) {

Expand Down Expand Up @@ -101,7 +101,7 @@ NULL
## Merge in Pr(Race | Surname) if necessary
if (census.surname) {
if (!(surname.year %in% c(2000, 2010, 2020))) {
stop(paste(surname.year, "is not a valid surname.year. It should be 2000, 2010 (default) or 2020."))
stop(paste(surname.year, "is not a valid surname.year. It should be 2000, 2010 or 2020 (default)."))
}
voter.file <- merge_surnames(voter.file, surname.year = surname.year, name.data = NULL, impute.missing = impute.missing)
} else {
Expand Down Expand Up @@ -268,7 +268,7 @@ predict_race_new <- function(voter.file, names.to.use, year = "2020",age = FALSE

# Check years
if (!(year %in% c("2000", "2010", "2020"))){
stop("Year should be one of 2000, 2010, or 2020.")
stop("Year should be one of 2000, 2010, or 2020 (default).")
}
# Define 2020 race marginal
race.margin <- c(r_whi=0.5783619, r_bla=0.1205021, r_his=0.1872988,
Expand Down

0 comments on commit 188da97

Please sign in to comment.