Skip to content

Commit

Permalink
Merge pull request #48 from UI-Research/new-indicators
Browse files Browse the repository at this point in the history
adjusting age over 64%
  • Loading branch information
wcurrangroome authored Oct 8, 2024
2 parents 0b2e0bd + fb371a5 commit 7618e20
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ inst/doc
*.csv
/doc/
/Meta/
.rds
*.rds
/inst
6 changes: 3 additions & 3 deletions R/compile_acs_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ internal_compute_acs_variables = function(.data) {
####----AGE----####
## creating combined, male and female counts by age group named, e.g., age_15_17_years
dplyr::across(
.cols = dplyr::matches("sex_by_age_female_.*years$"),
.cols = dplyr::matches("sex_by_age_female_.*years($|_over$)"),
.fns = ~ .x + get( dplyr::cur_column() %>% stringr::str_replace("female", "male")),
.names = "{stringr::str_replace(string = .col, pattern = 'sex_by_age_female_', replacement = 'age_')}"),
dplyr::across(
.cols = dplyr::matches("^age.*years$"),
.cols = dplyr::matches("^age.*years($|_over$)"),
.fns = ~ safe_divide(.x, sex_by_age_universe),
.names = "{.col}_percent")) %>%

Expand All @@ -100,7 +100,7 @@ internal_compute_acs_variables = function(.data) {
rowSums(dplyr::select(., age_under_5_years, age_5_9_years, age_10_14_years, age_15_17_years)),
sex_by_age_universe),
age_over_64_percent = safe_divide(
rowSums(dplyr::select(., dplyr::matches("age_(6(5|7)|7|8).*_years$"))),
rowSums(dplyr::select(., dplyr::matches("age_(6(5|7)|7|8).*_years($|_over$)"))),
sex_by_age_universe),

####----DISABILITY----####
Expand Down
26 changes: 12 additions & 14 deletions tests/testthat/test-compile_acs_data.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
# message("Update test data prior to testing, as needed.")
#
df = compile_acs_data(
variables = NULL,
years = c(2022),
geography = "tract",
states = c("CA", "TX"),
counties = NULL,
spatial = FALSE)

codebook = attr(df, "codebook")

saveRDS(object = df, file = file.path("inst", "test-data", "test_data_2024-08-24.rds"))
saveRDS(codebook, file = file.path("inst", "test-data", "codebook_2024-08-24.rds"))

df %>% dplyr::select(dplyr::matches("mobile")) %>% colnames()
# df = compile_acs_data(
# variables = NULL,
# years = c(2022),
# geography = "tract",
# states = c("CA", "TX"),
# counties = NULL,
# spatial = FALSE)
#
# codebook = attr(df, "codebook")
#
# saveRDS(object = df, file = file.path("inst", "test-data", "test_data_2024-08-24.rds"))
# saveRDS(codebook, file = file.path("inst", "test-data", "codebook_2024-08-24.rds"))

####----Tests----####
# All percentages have no values greater than one and no values less than zero
Expand Down

0 comments on commit 7618e20

Please sign in to comment.