Skip to content

Commit

Permalink
Fixes for all the things
Browse files Browse the repository at this point in the history
  • Loading branch information
1beb committed Feb 14, 2024
1 parent 9d8626a commit 7541cbb
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ Date Version Comment
2022-06-17 1.0.0 Updates to BISG, inclusion of fBISG and other package improvements
2022-10-04 1.0.1 Bug fixes for census url and census year
2023-06-12 2.0.0 Updated defaults to 2020 data, specifiy as next major version 2.0.
2024-02-15 3.0.0 Adding back age and sex functionality. Other improvements.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: wru
Title: Who are You? Bayesian Prediction of Racial Category Using Surname,
First Name, Middle Name, and Geolocation
Version: 3.0.0
Date: 2023-12-09
Date: 2024-02-14
Authors@R: c(
person("Kabir", "Khanna", , "[email protected]", role = "aut"),
person("Brandon", "Bertelsen", , "[email protected]", role = c("aut", "cre")),
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Generated by roxygen2: do not edit by hand

export(as_fips_code)
export(as_state_abbreviation)
export(format_legacy_data)
export(get_census_data)
export(predict_race)
Expand Down
9 changes: 6 additions & 3 deletions R/census_helper_v2.R
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,13 @@ census_helper_new <- function(
paste(do.call(paste, c(unique(voters.census[miss_ind, c("state",geo.merge)]),
sep="-")),
collapse = ", "))
if(skip_bad_geos == TRUE){
if(skip_bad_geos == TRUE) {
message("NOTE: Skipping unavailable geolocations. Returning partial data set.")
voters.census <- tidyr::drop_na(voters.census, r_whi)}
else(stop("Stopping predictions. Please revise census data and/or verify the correct year is being supplied. To skip these rows use 'skip_bad_geos = TRUE'"))
voters.census <- voters.census[!is.na(voters.census$r_whi),]
}
else {
stop("Stopping predictions. Please revise census data and/or verify the correct year is being supplied. To skip these rows use 'skip_bad_geos = TRUE'")
}
}

# }
Expand Down
4 changes: 4 additions & 0 deletions R/utils_state_fips.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
#' as_state_abbreviation(c("utah", "NM", 8, "04"))
#'
#' @keywords internal
#' @export
as_fips_code <- function(x) {
state_fips <- wru::state_fips
state_fips$state_code[
dplyr::coalesce(
match(toupper(x), state_fips$state),
Expand All @@ -63,7 +65,9 @@ as_fips_code <- function(x) {
}

#' @rdname as_fips_code
#' @export
as_state_abbreviation <- function(x) {
state_fips <- wru::state_fips
state_fips$state[
dplyr::coalesce(
match(toupper(x), state_fips$state),
Expand Down
2 changes: 1 addition & 1 deletion R/wru-internal.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
packageStartupMessage(
"\n",
"Please cite as:", "\n\n",
format(citation("wru"), style = "text"), "\n\n",
format(utils::citation("wru"), style = "text"), "\n\n",
"Note that wru 2.0.0 uses 2020 census data by default.", "\n",
'Use the argument `year = "2010"`, to replicate analyses produced with earlier package versions.',
"\n"
Expand Down

0 comments on commit 7541cbb

Please sign in to comment.