Skip to content

Commit 6efbc99

Browse files
Merge pull request #51 from UI-Research/hma
updating ia script
2 parents 07e836b + 732dd02 commit 6efbc99

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

R/get_ihp_registrations.R

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,15 @@ get_ihp_registrations = function(
9898
## in which case we assume we attribute all of the given record to non-missing county
9999
is.na(allocation_factor_zcta_to_county) & !is.na(geoid_county) ~ 1,
100100
TRUE ~ allocation_factor_zcta_to_county),
101-
state_name, state_abbreviation, state_code,
102101
geoid_county = dplyr::if_else(is.na(geoid_county), county_code, geoid_county),
103-
zcta_code = zip_code, geoid_tract, geoid_block_group,
102+
zcta_code = zip_code, geoid_tract, geoid_block_group, disaster_number,
104103
amount_individual_housing_program, amount_housing_assistance, amount_other_needs_assistance,
105104
amount_rental_assistance, amount_repairs, amount_replacement, amount_personal_property,
106-
amount_flood_insurance_premium_paid_by_fema)
105+
amount_flood_insurance_premium_paid_by_fema) %>%
106+
dplyr::left_join(
107+
tidycensus::fips_codes %>%
108+
dplyr::select(state_name, state_abbreviation = state, state_code, geoid_county = county_code) %>%
109+
dplyr::mutate(geoid_county = stringr::str_c(state_code, geoid_county)))
107110

108111
warning("
109112
County identifiers in the raw data from FEMA have high missingness. For this reason, the data returned by this function reflect a many-to-many
@@ -117,7 +120,6 @@ What your workflow should look like:
117120
118121
df |>
119122
dplyr::group_by(geoid_county) |>
120-
dplyr::mutate(afact = dplyr::if_else(is.na(afact), 1, afact)) |>
121123
dplyr::summarize(valid_registrations = sum(afact, na.rm = TRUE))")
122124

123125
message("
@@ -202,6 +204,6 @@ utils::globalVariables(c(
202204
"fip_amount", "food_need", "gross_income", "ha_amount", "ha_max", "household_composition",
203205
"ihp_amount", "ihp_max", "last_refresh", "ona_amount", "ona_max", "own_rent", "personal_property_amount",
204206
"ppfvl", "rpfvl", "repair_amount", "replacement_amount", "rental_assistance_amount", "shelter_need",
205-
"uuid", "zip_name", "zcta", "pop20", "state.abb", "ihp_registrations",
207+
"uuid", "zip_name", "zcta", "pop20", "state.abb", "ihp_registrations", "disaster_number",
206208
"amount_other_needs_assistance", "census_geoid", "geoid_block_group", "geoid_county",
207209
"geoid_tract", "zcta_code"))

0 commit comments

Comments
 (0)