Skip to content

Commit

Permalink
Resolve some NOTEs
Browse files Browse the repository at this point in the history
  • Loading branch information
kuriwaki committed Oct 26, 2024
1 parent 16cf1f9 commit c697fe5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Imports:
magrittr,
fs,
rlang,
Formula,
dplyr (>= 1.1.0),
tidyr,
haven (>= 2.1.0),
Expand Down
6 changes: 3 additions & 3 deletions R/cces_std-for-acs.R
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@ ccc_std_demographics <- function(tbl,
# hispanic conversion
if (wh_as_hisp && ("hispanic" %in% colnames(tbl_mod))) {
tbl_mod <- tbl_mod %>%
mutate(race = replace(race, race_cces_chr == "White" & hispanic == 1, race_cces_to_acs$race[3]))
mutate(race = replace(race, race_cces_chr == "White" & .data$hispanic == 1, race_cces_to_acs$race[3]))
}

if (bh_as_hisp && ("hispanic" %in% colnames(tbl_mod))) {
tbl_mod <- tbl_mod %>%
mutate(race = replace(race, race_cces_chr == "Black" & hispanic == 1, race_cces_to_acs$race[3]))
mutate(race = replace(race, race_cces_chr == "Black" & .data$hispanic == 1, race_cces_to_acs$race[3]))
}

if ((!is.null(wh_as_hisp) | !is.null(bh_as_hisp)) &
Expand All @@ -164,7 +164,7 @@ ccc_std_demographics <- function(tbl,
matches("weight"),
matches("(state|st|cd|dist)"),
matches("gender"),
female,
matches("^female$"),
matches("pid3$"),
matches("age"),
matches("educ"),
Expand Down
8 changes: 4 additions & 4 deletions R/district-coding.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#'@param state A vector of state names, preferably abbreviations.
#' If it is numeric, the function will assume they are FIPS codes
#' and translate them accordingly. If they have full names like "California"
#' instead of "CA", it will trnslate that too.
#' instead of "CA", it will translate that too. But you cannot mix different types.
#'@param num A vector of district codes
#'
#'@importFrom stringr str_pad
Expand All @@ -29,12 +29,12 @@ to_cd <- function(state, num) {

# State
if (inherits(state, "haven_labelled") | is.numeric(state)) {
fips_to_st <- deframe(select(states_key, st_fips, st))
fips_to_st <- deframe(select(states_key, .data$st_fips, .data$st))
state <- recode(as.numeric(state), !!!fips_to_st)
}

if (all(state %in% c(states_key$state))) {
state_to_st <- deframe(select(states_key, state, st))
if (all(state %in% c(ccesMRPprep::states_key$state))) {
state_to_st <- deframe(select(states_key, .data$state, .data$st))
state <- recode(state, !!!state_to_st)
}

Expand Down
2 changes: 1 addition & 1 deletion man/to_cd.Rd

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

0 comments on commit c697fe5

Please sign in to comment.