diff --git a/DESCRIPTION b/DESCRIPTION index 201b592..3dcee06 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -18,7 +18,7 @@ Maintainer: Will Mackey License: GPL-3 Description: This package provides data and functions for working with common structures and classifications used in Australia. Depends: - R (>= 3.5) + R (>= 3.5) Imports: dplyr (>= 0.7), lifecycle, @@ -33,11 +33,14 @@ Imports: parsedate Suggests: testthat, + curl, sf, here, ggplot2, bench Encoding: UTF-8 LazyData: true -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.2 +URL: https://runapp-aus.github.io/strayr/ +BugReports: https://github.com/runapp-aus/strayr/issues/ RdMacros: lifecycle diff --git a/R/seifa.R b/R/seifa.R index be6b3e9..f9794f8 100644 --- a/R/seifa.R +++ b/R/seifa.R @@ -14,7 +14,7 @@ #' \url{https://www.abs.gov.au/statistics/people/people-and-communities/socio-economic-indexes-areas-seifa-australia/2021} #' @param structure character value for the desired spatial area. Must be one of: -#' \itemize{ +#' \describe{ #' \item{sa1}{ - download size 51.6 MB} #' \item{sa2}{ - download size 1.9 MB} #' \item{lga}{ - download size 660 KB} @@ -22,7 +22,7 @@ #' \item{suburb}{ - download size 11.3 MB} #' } #' @param data_subclass character vector matching available SEIFA indexes: -#' \itemize{ +#' \describe{ #' \item{irsed}{ - Index of Relative Socio-economic Disadvantage} #' \item{irsead}{ - Index of Relative Socio-economic Advantage and Disadvantage} #' \item{ier}{ - Index of Economic Resources} @@ -297,18 +297,18 @@ get_seifa_index_sheet <- function(filename, sheetname, structure = c("sa1", "sa2 col_names = column_names, na = c("", "NA", "-") ) %>% - dplyr::filter(if_all(ends_with(c("_name","_code")), ~ !is.na(.x))) %>% - select(-starts_with("blank")) %>% - mutate( + dplyr::filter(dplyr::if_all(dplyr::ends_with(c("_name","_code")), ~ !is.na(.x))) %>% + dplyr::select(-dplyr::starts_with("blank")) %>% + dplyr::mutate( structure = structure, year = year ) %>% - mutate(across( - .cols = any_of(ends_with("_code")), # Specify the column name + dplyr::mutate(dplyr::across( + .cols = dplyr::any_of(ends_with("_code")), # Specify the column name .fns = ~ as.character(.) # Conditionally convert to character )) %>% - relocate(structure) + dplyr::relocate(structure) }) - + return(df) } diff --git a/R/sysdata.rda b/R/sysdata.rda index 184a25d..2fe9233 100644 Binary files a/R/sysdata.rda and b/R/sysdata.rda differ diff --git a/data-raw/create_anzsco2009.R b/data-raw/create_anzsco2009.R index 0c8bf38..c2a10af 100644 --- a/data-raw/create_anzsco2009.R +++ b/data-raw/create_anzsco2009.R @@ -20,44 +20,57 @@ download.file(anzsco_url, temp_path, mode = "wb") # Read raw <- readxl::read_excel(temp_path, - sheet = 6, - range = "A11:G1555", - col_names = FALSE) %>% + sheet = 6, + range = "A11:G1555", + col_names = FALSE +) %>% janitor::clean_names() # Extract each level: anzsco1 <- raw %>% filter(!is.na(x1)) %>% - select(anzsco1_code = 1, - anzsco1 = 2) %>% + select( + anzsco1_code = 1, + anzsco1 = 2 + ) %>% mutate(anzsco1_code = as.character(anzsco1_code)) anzsco2 <- raw %>% anti_join(anzsco1, by = c("x2" = "anzsco1")) %>% filter(!is.na(x2)) %>% - select(anzsco2_code = 2, - anzsco2 = 3) %>% + select( + anzsco2_code = 2, + anzsco2 = 3 + ) %>% mutate(anzsco1_code = substr(anzsco2_code, 1, 1)) anzsco3 <- raw %>% anti_join(anzsco1, by = c("x2" = "anzsco1")) %>% anti_join(anzsco2, by = c("x3" = "anzsco2")) %>% filter(!is.na(x3)) %>% - select(anzsco3_code = 3, - anzsco3 = 4) %>% - mutate(anzsco2_code = substr(anzsco3_code, 1, 2), - anzsco1_code = substr(anzsco2_code, 1, 1)) + select( + anzsco3_code = 3, + anzsco3 = 4 + ) %>% + mutate( + anzsco2_code = substr(anzsco3_code, 1, 2), + anzsco1_code = substr(anzsco2_code, 1, 1) + ) anzsco4 <- raw %>% anti_join(anzsco1, by = c("x2" = "anzsco1")) %>% anti_join(anzsco2, by = c("x3" = "anzsco2")) %>% anti_join(anzsco3, by = c("x4" = "anzsco3")) %>% filter(!is.na(x4)) %>% - select(anzsco4_code = 4, - anzsco4 = 5) %>% - mutate(anzsco3_code = substr(anzsco4_code, 1, 3), - anzsco2_code = substr(anzsco3_code, 1, 2), - anzsco1_code = substr(anzsco2_code, 1, 1)) + select( + anzsco4_code = 4, + anzsco4 = 5 + ) %>% + mutate( + anzsco3_code = substr(anzsco4_code, 1, 3), + anzsco2_code = substr(anzsco3_code, 1, 2), + anzsco1_code = substr(anzsco2_code, 1, 1) + ) anzsco6 <- raw %>% anti_join(anzsco1, by = c("x2" = "anzsco1")) %>% @@ -65,13 +78,17 @@ anzsco6 <- raw %>% anti_join(anzsco3, by = c("x4" = "anzsco3")) %>% anti_join(anzsco4, by = c("x5" = "anzsco4")) %>% filter(!is.na(x5)) %>% - select(anzsco6_code = 5, - anzsco6 = 6, - skill_level = 7) %>% - mutate(anzsco4_code = substr(anzsco6_code, 1, 4), - anzsco3_code = substr(anzsco4_code, 1, 3), - anzsco2_code = substr(anzsco3_code, 1, 2), - anzsco1_code = substr(anzsco2_code, 1, 1)) + select( + anzsco6_code = 5, + anzsco6 = 6, + skill_level = 7 + ) %>% + mutate( + anzsco4_code = substr(anzsco6_code, 1, 4), + anzsco3_code = substr(anzsco4_code, 1, 3), + anzsco2_code = substr(anzsco3_code, 1, 2), + anzsco1_code = substr(anzsco2_code, 1, 1) + ) # Join into wide anzscoupation list comb <- anzsco1 %>% @@ -86,39 +103,47 @@ comb <- anzsco1 %>% nfd1 <- comb %>% select(anzsco1_code, anzsco1) %>% distinct() %>% - mutate(anzsco2 = glue("{anzsco1}, nfd"), - anzsco2_code = glue("{anzsco1_code}0"), - anzsco3 = glue("{anzsco1}, nfd"), - anzsco3_code = glue("{anzsco1_code}00"), - anzsco4 = glue("{anzsco1}, nfd"), - anzsco4_code = glue("{anzsco1_code}000"), - anzsco6 = glue("{anzsco1}, nfd"), - anzsco6_code = glue("{anzsco1_code}00000")) + mutate( + anzsco2 = glue("{anzsco1}, nfd"), + anzsco2_code = glue("{anzsco1_code}0"), + anzsco3 = glue("{anzsco1}, nfd"), + anzsco3_code = glue("{anzsco1_code}00"), + anzsco4 = glue("{anzsco1}, nfd"), + anzsco4_code = glue("{anzsco1_code}000"), + anzsco6 = glue("{anzsco1}, nfd"), + anzsco6_code = glue("{anzsco1_code}00000") + ) nfd2 <- comb %>% select(anzsco1_code, anzsco1, anzsco2_code, anzsco2) %>% distinct() %>% - mutate(anzsco3 = glue("{anzsco2}, nfd"), - anzsco3_code = glue("{anzsco2_code}0"), - anzsco4 = glue("{anzsco2}, nfd"), - anzsco4_code = glue("{anzsco2_code}00"), - anzsco6 = glue("{anzsco2}, nfd"), - anzsco6_code = glue("{anzsco2_code}0000")) + mutate( + anzsco3 = glue("{anzsco2}, nfd"), + anzsco3_code = glue("{anzsco2_code}0"), + anzsco4 = glue("{anzsco2}, nfd"), + anzsco4_code = glue("{anzsco2_code}00"), + anzsco6 = glue("{anzsco2}, nfd"), + anzsco6_code = glue("{anzsco2_code}0000") + ) nfd3 <- comb %>% select(anzsco1_code, anzsco1, anzsco2_code, anzsco2, anzsco3_code, anzsco3) %>% distinct() %>% - mutate(anzsco4 = glue("{anzsco3}, nfd"), - anzsco4_code = glue("{anzsco3_code}0"), - anzsco6 = glue("{anzsco3}, nfd"), - anzsco6_code = glue("{anzsco3_code}000")) + mutate( + anzsco4 = glue("{anzsco3}, nfd"), + anzsco4_code = glue("{anzsco3_code}0"), + anzsco6 = glue("{anzsco3}, nfd"), + anzsco6_code = glue("{anzsco3_code}000") + ) anzsco2009 <- comb %>% bind_rows(nfd1, nfd2, nfd3) %>% - arrange(anzsco1_code, anzsco2_code, anzsco3_code, - anzsco4_code, anzsco6_code) %>% - mutate(across(.fns = as.character)) %>% + arrange( + anzsco1_code, anzsco2_code, anzsco3_code, + anzsco4_code, anzsco6_code + ) %>% + mutate(across(everything(), .fns = as.character)) %>% arrange(anzsco6_code) if (include_factor_variants) { @@ -129,15 +154,17 @@ if (include_factor_variants) { anzsco3_f = as_factor(anzsco3), anzsco4_f = as_factor(anzsco4), anzsco6_f = as_factor(anzsco6), - skill_level = as_factor(skill_level)) %>% + skill_level = as_factor(skill_level) + ) %>% # order - select(anzsco1_code, anzsco1, anzsco1_f, - anzsco2_code, anzsco2, anzsco2_f, - anzsco3_code, anzsco3, anzsco3_f, - anzsco4_code, anzsco4, anzsco4_f, - anzsco6_code, anzsco6, anzsco6_f, - skill_level) - + select( + anzsco1_code, anzsco1, anzsco1_f, + anzsco2_code, anzsco2, anzsco2_f, + anzsco3_code, anzsco3, anzsco3_f, + anzsco4_code, anzsco4, anzsco4_f, + anzsco6_code, anzsco6, anzsco6_f, + skill_level + ) } # Rename using new conventions: https://github.com/runapp-aus/abscorr/issues/17 diff --git a/data-raw/create_anzsco2013.R b/data-raw/create_anzsco2013.R index 26df43c..642245b 100644 --- a/data-raw/create_anzsco2013.R +++ b/data-raw/create_anzsco2013.R @@ -20,44 +20,57 @@ download.file(anzsco_url, temp_path, mode = "wb") # Read raw <- readxl::read_excel(temp_path, - sheet = 6, - range = "A11:G1555", - col_names = FALSE) %>% + sheet = 6, + range = "A11:G1555", + col_names = FALSE +) %>% janitor::clean_names() # Extract each level: anzsco1 <- raw %>% filter(!is.na(x1)) %>% - select(anzsco1_code = 1, - anzsco1 = 2) %>% + select( + anzsco1_code = 1, + anzsco1 = 2 + ) %>% mutate(anzsco1_code = as.character(anzsco1_code)) anzsco2 <- raw %>% anti_join(anzsco1, by = c("x2" = "anzsco1")) %>% filter(!is.na(x2)) %>% - select(anzsco2_code = 2, - anzsco2 = 3) %>% + select( + anzsco2_code = 2, + anzsco2 = 3 + ) %>% mutate(anzsco1_code = substr(anzsco2_code, 1, 1)) anzsco3 <- raw %>% anti_join(anzsco1, by = c("x2" = "anzsco1")) %>% anti_join(anzsco2, by = c("x3" = "anzsco2")) %>% filter(!is.na(x3)) %>% - select(anzsco3_code = 3, - anzsco3 = 4) %>% - mutate(anzsco2_code = substr(anzsco3_code, 1, 2), - anzsco1_code = substr(anzsco2_code, 1, 1)) + select( + anzsco3_code = 3, + anzsco3 = 4 + ) %>% + mutate( + anzsco2_code = substr(anzsco3_code, 1, 2), + anzsco1_code = substr(anzsco2_code, 1, 1) + ) anzsco4 <- raw %>% anti_join(anzsco1, by = c("x2" = "anzsco1")) %>% anti_join(anzsco2, by = c("x3" = "anzsco2")) %>% anti_join(anzsco3, by = c("x4" = "anzsco3")) %>% filter(!is.na(x4)) %>% - select(anzsco4_code = 4, - anzsco4 = 5) %>% - mutate(anzsco3_code = substr(anzsco4_code, 1, 3), - anzsco2_code = substr(anzsco3_code, 1, 2), - anzsco1_code = substr(anzsco2_code, 1, 1)) + select( + anzsco4_code = 4, + anzsco4 = 5 + ) %>% + mutate( + anzsco3_code = substr(anzsco4_code, 1, 3), + anzsco2_code = substr(anzsco3_code, 1, 2), + anzsco1_code = substr(anzsco2_code, 1, 1) + ) anzsco6 <- raw %>% anti_join(anzsco1, by = c("x2" = "anzsco1")) %>% @@ -65,13 +78,17 @@ anzsco6 <- raw %>% anti_join(anzsco3, by = c("x4" = "anzsco3")) %>% anti_join(anzsco4, by = c("x5" = "anzsco4")) %>% filter(!is.na(x5)) %>% - select(anzsco6_code = 5, - anzsco6 = 6, - skill_level = 7) %>% - mutate(anzsco4_code = substr(anzsco6_code, 1, 4), - anzsco3_code = substr(anzsco4_code, 1, 3), - anzsco2_code = substr(anzsco3_code, 1, 2), - anzsco1_code = substr(anzsco2_code, 1, 1)) + select( + anzsco6_code = 5, + anzsco6 = 6, + skill_level = 7 + ) %>% + mutate( + anzsco4_code = substr(anzsco6_code, 1, 4), + anzsco3_code = substr(anzsco4_code, 1, 3), + anzsco2_code = substr(anzsco3_code, 1, 2), + anzsco1_code = substr(anzsco2_code, 1, 1) + ) # Join into wide anzscoupation list comb <- anzsco1 %>% @@ -86,39 +103,47 @@ comb <- anzsco1 %>% nfd1 <- comb %>% select(anzsco1_code, anzsco1) %>% distinct() %>% - mutate(anzsco2 = glue("{anzsco1}, nfd"), - anzsco2_code = glue("{anzsco1_code}0"), - anzsco3 = glue("{anzsco1}, nfd"), - anzsco3_code = glue("{anzsco1_code}00"), - anzsco4 = glue("{anzsco1}, nfd"), - anzsco4_code = glue("{anzsco1_code}000"), - anzsco6 = glue("{anzsco1}, nfd"), - anzsco6_code = glue("{anzsco1_code}00000")) + mutate( + anzsco2 = glue("{anzsco1}, nfd"), + anzsco2_code = glue("{anzsco1_code}0"), + anzsco3 = glue("{anzsco1}, nfd"), + anzsco3_code = glue("{anzsco1_code}00"), + anzsco4 = glue("{anzsco1}, nfd"), + anzsco4_code = glue("{anzsco1_code}000"), + anzsco6 = glue("{anzsco1}, nfd"), + anzsco6_code = glue("{anzsco1_code}00000") + ) nfd2 <- comb %>% select(anzsco1_code, anzsco1, anzsco2_code, anzsco2) %>% distinct() %>% - mutate(anzsco3 = glue("{anzsco2}, nfd"), - anzsco3_code = glue("{anzsco2_code}0"), - anzsco4 = glue("{anzsco2}, nfd"), - anzsco4_code = glue("{anzsco2_code}00"), - anzsco6 = glue("{anzsco2}, nfd"), - anzsco6_code = glue("{anzsco2_code}0000")) + mutate( + anzsco3 = glue("{anzsco2}, nfd"), + anzsco3_code = glue("{anzsco2_code}0"), + anzsco4 = glue("{anzsco2}, nfd"), + anzsco4_code = glue("{anzsco2_code}00"), + anzsco6 = glue("{anzsco2}, nfd"), + anzsco6_code = glue("{anzsco2_code}0000") + ) nfd3 <- comb %>% select(anzsco1_code, anzsco1, anzsco2_code, anzsco2, anzsco3_code, anzsco3) %>% distinct() %>% - mutate(anzsco4 = glue("{anzsco3}, nfd"), - anzsco4_code = glue("{anzsco3_code}0"), - anzsco6 = glue("{anzsco3}, nfd"), - anzsco6_code = glue("{anzsco3_code}000")) + mutate( + anzsco4 = glue("{anzsco3}, nfd"), + anzsco4_code = glue("{anzsco3_code}0"), + anzsco6 = glue("{anzsco3}, nfd"), + anzsco6_code = glue("{anzsco3_code}000") + ) anzsco2013 <- comb %>% bind_rows(nfd1, nfd2, nfd3) %>% - arrange(anzsco1_code, anzsco2_code, anzsco3_code, - anzsco4_code, anzsco6_code) %>% - mutate(across(.fns = as.character)) %>% + arrange( + anzsco1_code, anzsco2_code, anzsco3_code, + anzsco4_code, anzsco6_code + ) %>% + mutate(across(everything(), .fns = as.character)) %>% arrange(anzsco6_code) if (include_factor_variants) { @@ -129,15 +154,17 @@ if (include_factor_variants) { anzsco3_f = as_factor(anzsco3), anzsco4_f = as_factor(anzsco4), anzsco6_f = as_factor(anzsco6), - skill_level = as_factor(skill_level)) %>% + skill_level = as_factor(skill_level) + ) %>% # order - select(anzsco1_code, anzsco1, anzsco1_f, - anzsco2_code, anzsco2, anzsco2_f, - anzsco3_code, anzsco3, anzsco3_f, - anzsco4_code, anzsco4, anzsco4_f, - anzsco6_code, anzsco6, anzsco6_f, - skill_level) - + select( + anzsco1_code, anzsco1, anzsco1_f, + anzsco2_code, anzsco2, anzsco2_f, + anzsco3_code, anzsco3, anzsco3_f, + anzsco4_code, anzsco4, anzsco4_f, + anzsco6_code, anzsco6, anzsco6_f, + skill_level + ) } # Rename using new conventions: https://github.com/runapp-aus/abscorr/issues/17 diff --git a/data-raw/create_anzsco2019.R b/data-raw/create_anzsco2019.R index b0cc1f6..ce65522 100644 --- a/data-raw/create_anzsco2019.R +++ b/data-raw/create_anzsco2019.R @@ -118,7 +118,7 @@ anzsco2019 <- comb %>% bind_rows(nfd1, nfd2, nfd3) %>% arrange(anzsco1_code, anzsco2_code, anzsco3_code, anzsco4_code, anzsco6_code) %>% - mutate(across(.fns = as.character)) %>% + mutate(across(everything(), .fns = as.character)) %>% arrange(anzsco6_code) if (include_factor_variants) { diff --git a/data-raw/create_anzsco2021.R b/data-raw/create_anzsco2021.R index 6f49cb1..e5eecd4 100644 --- a/data-raw/create_anzsco2021.R +++ b/data-raw/create_anzsco2021.R @@ -118,7 +118,7 @@ anzsco2021 <- comb %>% bind_rows(nfd1, nfd2, nfd3) %>% arrange(anzsco1_code, anzsco2_code, anzsco3_code, anzsco4_code, anzsco6_code) %>% - mutate(across(.fns = as.character)) %>% + mutate(across(everything(), .fns = as.character)) %>% arrange(anzsco6_code) if (include_factor_variants) { diff --git a/data-raw/create_anzsic2006.R b/data-raw/create_anzsic2006.R index 23c6c03..1d32b4d 100644 --- a/data-raw/create_anzsic2006.R +++ b/data-raw/create_anzsic2006.R @@ -1,4 +1,3 @@ - # Reading and cleaning ANZSIC correspondence library(tidyverse) @@ -74,23 +73,27 @@ anzsic_2006_final <- # Finalise data frame; noting that we are avoiding the nfd complication for now anzsic2006 <- anzsic_2006_final %>% - arrange(anzsic_division_code, - anzsic_subdivision_code, - anzsic_group_code, - anzsic_class_code) %>% - mutate(across(.fns = as.character)) + arrange( + anzsic_division_code, + anzsic_subdivision_code, + anzsic_group_code, + anzsic_class_code + ) %>% + mutate(across(everything(), .fns = as.character)) if (include_factor_variants) { anzsic2006 <- anzsic2006 %>% mutate(across(ends_with("title"), fct_inorder, .names = "{.col}_f")) } -anzsic2006 <- anzsic2006 %>% +anzsic2006 <- anzsic2006 %>% rename_with(~ str_remove_all(., "\\_title"), everything()) %>% - arrange(anzsic_division_code, - anzsic_subdivision_code, - anzsic_group_code, - anzsic_class_code) + arrange( + anzsic_division_code, + anzsic_subdivision_code, + anzsic_group_code, + anzsic_class_code + ) anzsic_dictionary <- make_dictionary(anzsic2006) diff --git a/data-raw/create_anzsic_isic_correspondence.R b/data-raw/create_anzsic_isic_correspondence.R index 5afb7a2..e66381f 100644 --- a/data-raw/create_anzsic_isic_correspondence.R +++ b/data-raw/create_anzsic_isic_correspondence.R @@ -1,4 +1,3 @@ - # Reading and cleaning ANZSIC correspondence library(tidyverse) @@ -17,10 +16,12 @@ df <- url %>% # bind tables together anzsic_isic_temp <- purrr::list_rbind(df) %>% - rename(anzsic_class_code = 2, - anzsic_class_title = 3, - isic_class_code = 4, - isic_class_title = 5) %>% + rename( + anzsic_class_code = 2, + anzsic_class_title = 3, + isic_class_code = 4, + isic_class_title = 5 + ) %>% select(2:5) anzsic_isic_temp[anzsic_isic_temp == ""] <- NA @@ -36,19 +37,23 @@ anzsic_isic_fill <- # Finalise data frame; noting that we are avoiding the nfd complication for now anzsic_isic <- anzsic_isic_fill %>% - arrange(anzsic_class_code, - isic_class_code) %>% - mutate(across(.fns = as.character)) + arrange( + anzsic_class_code, + isic_class_code + ) %>% + mutate(across(everything(), .fns = as.character)) if (include_factor_variants) { anzsic_isic <- anzsic_isic %>% mutate(across(ends_with("title"), fct_inorder, .names = "{.col}_f")) } -anzsic_isic <- anzsic_isic %>% +anzsic_isic <- anzsic_isic %>% rename_with(~ str_remove_all(., "\\_title"), everything()) %>% - arrange(anzsic_class_code, - isic_class_code) + arrange( + anzsic_class_code, + isic_class_code + ) anzsic_isic_dictionary <- make_dictionary(anzsic_isic) diff --git a/data-raw/create_asced_foe2001.R b/data-raw/create_asced_foe2001.R index ef996e3..e0ce775 100644 --- a/data-raw/create_asced_foe2001.R +++ b/data-raw/create_asced_foe2001.R @@ -21,16 +21,19 @@ download.file(asced_url, temp_path, mode = "wb") # Read long list raw <- readxl::read_excel(temp_path, - sheet = 3, - range = "A8:D446", - col_names = FALSE) %>% + sheet = 3, + range = "A8:D446", + col_names = FALSE +) %>% janitor::clean_names() # Extract each level: foe2 <- raw %>% filter(!is.na(x1)) %>% - select(foe2_code = 1, - foe2 = 2) %>% + select( + foe2_code = 1, + foe2 = 2 + ) %>% mutate(foe2_code = as.character(foe2_code)) @@ -38,8 +41,10 @@ foe4 <- raw %>% mutate(x2 = to_title(x2)) %>% anti_join(foe2, by = c("x2" = "foe2")) %>% filter(!is.na(x2)) %>% - select(foe4_code = 2, - foe4 = 3) %>% + select( + foe4_code = 2, + foe4 = 3 + ) %>% mutate(foe2_code = substr(foe4_code, 1, 2)) @@ -47,10 +52,14 @@ foe6 <- raw %>% anti_join(foe2, by = c("x2" = "foe2")) %>% anti_join(foe4, by = c("x3" = "foe4")) %>% filter(!is.na(x3)) %>% - select(foe6_code = 3, - foe6 = 4) %>% - mutate(foe4_code = substr(foe6_code, 1, 4), - foe2_code = substr(foe4_code, 1, 2)) + select( + foe6_code = 3, + foe6 = 4 + ) %>% + mutate( + foe4_code = substr(foe6_code, 1, 4), + foe2_code = substr(foe4_code, 1, 2) + ) # Join into wide ascedupation list @@ -64,30 +73,38 @@ comb <- foe2 %>% nfd2 <- comb %>% select(foe2_code, foe2) %>% distinct() %>% - mutate(foe4 = glue("{foe2}, nfd"), - foe4_code = glue("{foe2_code}00"), - foe6 = glue("{foe2}, nfd"), - foe6_code = glue("{foe2_code}0000")) + mutate( + foe4 = glue("{foe2}, nfd"), + foe4_code = glue("{foe2_code}00"), + foe6 = glue("{foe2}, nfd"), + foe6_code = glue("{foe2_code}0000") + ) nfd4 <- comb %>% select(foe2_code, foe2, foe4_code, foe4) %>% distinct() %>% - mutate(foe6 = glue("{foe4}, nfd"), - foe6_code = glue("{foe4_code}00")) + mutate( + foe6 = glue("{foe4}, nfd"), + foe6_code = glue("{foe4_code}00") + ) asced_foe2001 <- bind_rows(comb, nfd2, nfd4) %>% arrange(foe2_code, foe4_code, foe6_code) %>% - mutate(across(.fns = as.character)) + mutate(across(everything(), .fns = as.character)) if (include_factor_variants) { asced_foe2001 <- asced_foe2001 %>% - mutate(foe2_f = fct_inorder(foe2), - foe4_f = fct_inorder(foe4), - foe6_f = fct_inorder(foe6)) %>% - select(foe2_code, foe2, foe2_f, - foe4_code, foe4, foe4_f, - foe6_code, foe6, foe6_f) + mutate( + foe2_f = fct_inorder(foe2), + foe4_f = fct_inorder(foe4), + foe6_f = fct_inorder(foe6) + ) %>% + select( + foe2_code, foe2, foe2_f, + foe4_code, foe4, foe4_f, + foe6_code, foe6, foe6_f + ) } # Rename using new conventions: https://github.com/runapp-aus/abscorr/issues/17 diff --git a/data-raw/create_asced_qual2001.R b/data-raw/create_asced_qual2001.R index b578a14..ad0e8f9 100644 --- a/data-raw/create_asced_qual2001.R +++ b/data-raw/create_asced_qual2001.R @@ -19,52 +19,69 @@ download.file(asced_url, temp_path, mode = "wb") # Read long list raw <- readxl::read_excel(temp_path, - sheet = 2, - range = "A8:D95", - col_names = FALSE) %>% + sheet = 2, + range = "A8:D95", + col_names = FALSE +) %>% janitor::clean_names() # Extract each level: qual1 <- raw %>% filter(!is.na(x1)) %>% - select(qual1_code = 1, - qual1 = 2) %>% - mutate(qual1_f = str_to_title(qual1), # "Natural And Physical Sciences" - qual1_f = tools::toTitleCase(qual1_f), - qual1_f = as_factor(qual1_f), - qual1_code = as.character(qual1_code)) + select( + qual1_code = 1, + qual1 = 2 + ) %>% + mutate( + qual1_f = str_to_title(qual1), # "Natural And Physical Sciences" + qual1_f = tools::toTitleCase(qual1_f), + qual1_f = as_factor(qual1_f), + qual1_code = as.character(qual1_code) + ) qual2 <- raw %>% anti_join(qual1, by = c("x2" = "qual1")) %>% filter(!is.na(x2)) %>% - select(qual2_code = 2, - qual2 = 3) %>% - mutate(qual2_f = as_factor(qual2), - qual1_code = substr(qual2_code, 1, 1)) + select( + qual2_code = 2, + qual2 = 3 + ) %>% + mutate( + qual2_f = as_factor(qual2), + qual1_code = substr(qual2_code, 1, 1) + ) qual3 <- raw %>% anti_join(qual1, by = c("x2" = "qual1")) %>% anti_join(qual2, by = c("x3" = "qual2")) %>% filter(!is.na(x3)) %>% - select(qual3_code = 3, - qual3 = 4) %>% - mutate(qual3_f = as_factor(qual3), - qual2_code = substr(qual3_code, 1, 2), - qual1_code = substr(qual2_code, 1, 1)) + select( + qual3_code = 3, + qual3 = 4 + ) %>% + mutate( + qual3_f = as_factor(qual3), + qual2_code = substr(qual3_code, 1, 2), + qual1_code = substr(qual2_code, 1, 1) + ) # Join into wide ascedupation list asced_qual2001 <- qual1 %>% left_join(qual2) %>% left_join(qual3) %>% - mutate(qual1 = str_to_title(qual1), # "Natural And Physical Sciences" - qual1 = tools::toTitleCase(qual1)) # "Natural and Physical Sciences" + mutate( + qual1 = str_to_title(qual1), # "Natural And Physical Sciences" + qual1 = tools::toTitleCase(qual1) + ) # "Natural and Physical Sciences" if (!include_factor_variants) { asced_qual2001 <- asced_qual2001 %>% - select(qual1_code, qual1, - qual2_code, qual2, - qual3_code, qual3) + select( + qual1_code, qual1, + qual2_code, qual2, + qual3_code, qual3 + ) } asced_qual_dictionary <- make_dictionary(asced_qual2001) diff --git a/data-raw/create_au_holidays.R b/data-raw/create_au_holidays.R index f974e30..6beee06 100644 --- a/data-raw/create_au_holidays.R +++ b/data-raw/create_au_holidays.R @@ -16,6 +16,7 @@ raw_data <- package$resources %>% list_rbind() auholidays <- raw_data %>% + dplyr::filter(!is.na(Date)) %>% # 'Friday before the AFL Grand Final' not given a date in VIC holiday data transmute( Date = ymd(Date), Name = coalesce(`Holiday Name`), diff --git a/data/anzsco2009.rda b/data/anzsco2009.rda index 2c9f6f0..21f233f 100644 Binary files a/data/anzsco2009.rda and b/data/anzsco2009.rda differ diff --git a/data/anzsco2013.rda b/data/anzsco2013.rda index 8314ddf..425d24e 100644 Binary files a/data/anzsco2013.rda and b/data/anzsco2013.rda differ diff --git a/data/anzsco2019.rda b/data/anzsco2019.rda index 1f7a4c8..3e8dd25 100644 Binary files a/data/anzsco2019.rda and b/data/anzsco2019.rda differ diff --git a/data/anzsco2021.rda b/data/anzsco2021.rda index ec75ead..714c30e 100644 Binary files a/data/anzsco2021.rda and b/data/anzsco2021.rda differ diff --git a/data/anzsco2022.rda b/data/anzsco2022.rda index 517c32f..b3cba79 100644 Binary files a/data/anzsco2022.rda and b/data/anzsco2022.rda differ diff --git a/data/anzsic2006.rda b/data/anzsic2006.rda index b721718..30f20b7 100644 Binary files a/data/anzsic2006.rda and b/data/anzsic2006.rda differ diff --git a/data/anzsic_isic.rda b/data/anzsic_isic.rda index cd809e9..a5da4d6 100644 Binary files a/data/anzsic_isic.rda and b/data/anzsic_isic.rda differ diff --git a/data/asced_foe2001.rda b/data/asced_foe2001.rda index b437a34..fdb57a2 100644 Binary files a/data/asced_foe2001.rda and b/data/asced_foe2001.rda differ diff --git a/data/asced_qual2001.rda b/data/asced_qual2001.rda index 8a5e7a2..f61c2ef 100644 Binary files a/data/asced_qual2001.rda and b/data/asced_qual2001.rda differ diff --git a/data/auholidays.rda b/data/auholidays.rda index ad78f47..f4b2466 100644 Binary files a/data/auholidays.rda and b/data/auholidays.rda differ diff --git a/data/palette_state_name_2016.rda b/data/palette_state_name_2016.rda index 941276c..fcfff90 100644 Binary files a/data/palette_state_name_2016.rda and b/data/palette_state_name_2016.rda differ diff --git a/data/school_terms.rda b/data/school_terms.rda index 80b8f62..09a9cf9 100644 Binary files a/data/school_terms.rda and b/data/school_terms.rda differ diff --git a/data/state_abb_au.rda b/data/state_abb_au.rda index ef55af9..8c3449c 100644 Binary files a/data/state_abb_au.rda and b/data/state_abb_au.rda differ diff --git a/data/state_name_au.rda b/data/state_name_au.rda index 6b7a357..0036b99 100644 Binary files a/data/state_name_au.rda and b/data/state_name_au.rda differ diff --git a/man/get_seifa.Rd b/man/get_seifa.Rd index 7a6b679..18edd58 100644 --- a/man/get_seifa.Rd +++ b/man/get_seifa.Rd @@ -12,7 +12,7 @@ get_seifa( } \arguments{ \item{structure}{character value for the desired spatial area. Must be one of: -\itemize{ +\describe{ \item{sa1}{ - download size 51.6 MB} \item{sa2}{ - download size 1.9 MB} \item{lga}{ - download size 660 KB} @@ -21,7 +21,7 @@ get_seifa( }} \item{data_subclass}{character vector matching available SEIFA indexes: -\itemize{ +\describe{ \item{irsed}{ - Index of Relative Socio-economic Disadvantage} \item{irsead}{ - Index of Relative Socio-economic Advantage and Disadvantage} \item{ier}{ - Index of Economic Resources} diff --git a/man/get_seifa_index_sheet.Rd b/man/get_seifa_index_sheet.Rd index afcf52f..6547628 100644 --- a/man/get_seifa_index_sheet.Rd +++ b/man/get_seifa_index_sheet.Rd @@ -21,7 +21,7 @@ get_seifa_index_sheet( important as the shape of the data in the ABS spreadsheets if different for some structures.} \item{data_subclass}{character vector matching available SEIFA indexes: -\itemize{ +\describe{ \item{irsed}{ - Index of Relative Socio-economic Disadvantage} \item{irsead}{ - Index of Relative Socio-economic Advantage and Disadvantage} \item{ier}{ - Index of Economic Resources} diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index 48b0d6d..fd3712b 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -1,4 +1,4 @@ -URL: https://runapp-aus.github.io/strayr/ +url: https://runapp-aus.github.io/strayr/ repo: url: