Skip to content

Commit

Permalink
Merge pull request #47 from UI-Research/new-indicators
Browse files Browse the repository at this point in the history
New indicators
  • Loading branch information
wcurrangroome authored Sep 30, 2024
2 parents 25f5762 + 9b42511 commit 0b2e0bd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ inst/doc
*.csv
/doc/
/Meta/
*.rds
.rds
/inst
6 changes: 6 additions & 0 deletions R/compile_acs_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ internal_compute_acs_variables = function(.data) {
.fns = ~ safe_divide(.x, get( dplyr::cur_column() %>% stringr::str_replace("owner", "renter_owner") )),
.names = "{.col}_percent"),

## units in structure
dplyr::across(
.cols = c(dplyr::matches("^units_in_structure"), -dplyr::matches("universe|householder")),
.fns = ~ safe_divide(.x, units_in_structure_universe),
.names = "{.col}_percent"),

## units in structure, both tenures
## (sums)
dplyr::across( ## summing renter- and owner-occupied estimates
Expand Down
4 changes: 4 additions & 0 deletions R/list_acs_variables.R
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,16 @@ list_acs_variables = function(year = "2022") {
## race-specific tables, just remove the "_", a la: select_variables(variable_name = "B18101")

####----HOUSING---####

## TENURE (by race)
select_variables("B25003"),

## TENURE BY OCCUPANTS PER ROOM
select_variables("B25014"),

## UNITS IN STRUCTURE
select_variables("B25024"),

## TENURE BY UNITS IN STRUCTURE
select_variables("B25032"),

Expand Down
26 changes: 14 additions & 12 deletions tests/testthat/test-compile_acs_data.R
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# 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 = 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()

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

0 comments on commit 0b2e0bd

Please sign in to comment.