Skip to content

Commit

Permalink
spatial fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wcurrangroome committed Nov 11, 2024
1 parent 74de9dc commit afee344
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion R/compile_acs_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ geographies over time should be thoroughly quality checked.\n")

## join geometries, calculate population density, drop geometry attribute if spatial == FALSE
dplyr::right_join(geometries, by = c("GEOID", "data_source_year"), relationship = "one-to-one") %>%
{if (spatial == FALSE) sf::st_drop_geometry(.) else sf::st_as_sf(.) } %>%
dplyr::mutate(population_density_land_sq_kilometer = safe_divide(total_population_universe, area_land_sq_kilometer)) %>%
dplyr::left_join(
.,
Expand All @@ -485,7 +486,7 @@ geographies over time should be thoroughly quality checked.\n")
attr(df_calculated_estimates, "codebook") = codebook

df_cvs = calculate_cvs(df_calculated_estimates) %>%
{if (spatial == FALSE) sf::st_drop_geometry(.) else sf::st_as_sf(.) }
{if (spatial == FALSE) . else dplyr::right_join(., geometries, by = c("GEOID", "data_source_year"), relationship = "one-to-one")}

## attach the codebook as an attribute named "codebook" to the returned dataset
attr(df_cvs, "codebook") = codebook
Expand Down

0 comments on commit afee344

Please sign in to comment.