Skip to content

Commit

Permalink
deprecated selecting vector syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
caropradier committed Sep 11, 2023
1 parent 2de8a05 commit 88ab6ae
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion R/calculate_errors.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ calculate_errors <- function(value, codigo_aglo = "Total", periodo_eph = "2014.0
# Operacion
tabla_referencia <- eph::errores_muestrales %>%
dplyr::filter(codigo == codigo_aglo & periodo == periodo_eph) %>%
dplyr::select(x, measure)
dplyr::select(all_of(c("x", measure)))

find_closest <- function(y) {
tabla_referencia[[measure]][which.min(abs(tabla_referencia[["x"]] - y))]
Expand Down
2 changes: 1 addition & 1 deletion R/calculate_poverty.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ calculate_poverty <- function(base, basket, print_summary = TRUE, window = "quar
TRUE ~ situacion
)
) %>%
dplyr::select(-adequi, -periodo, -CBA, -CBT)
dplyr::select(-any_of(c("adequi", "periodo", "CBA", "CBT")))

if (print_summary) {
if (window == "quarter") {
Expand Down
4 changes: 2 additions & 2 deletions R/calculate_tabulates.R
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ calculate_tabulates <- function(base,
dplyr::mutate(aux = sum(valor, na.rm = TRUE)) %>%
dplyr::ungroup() %>%
dplyr::mutate(prop = round((valor / aux) * 100, digits)) %>%
dplyr::select(-valor, -aux) %>%
dplyr::select(-any_of(c("valor", "aux"))) %>%
tidyr::pivot_wider(names_from = var, values_from = prop)

if (add.totals == "col") {
Expand Down Expand Up @@ -299,7 +299,7 @@ calculate_tabulates <- function(base,
perc_row <- tabulado %>%
dplyr::mutate(aux = rowSums(dplyr::across(dplyr::where(is.numeric)))) %>%
dplyr::mutate(dplyr::across(c(names(tabulado)[2:ncol(tabulado)]), function(x) round((x / aux) * 100, digits))) %>%
dplyr::select(-aux)
dplyr::select(-any_of(c("aux")))


if (add.totals == "col") {
Expand Down
6 changes: 3 additions & 3 deletions R/get_eahu.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ get_eahu <- function(year = 2010,
dplyr::mutate(filter_col = purrr::map_lgl(error, ~ !is.null(.x))) %>%
dplyr::filter(filter_col) %>%
dplyr::mutate(error_message = purrr::map(error, ~ purrr::pluck(.x, 1))) %>%
dplyr::select(-microdata, -error) %>%
dplyr::select(-any_of(c("microdata", "error"))) %>%
tidyr::unnest(cols = c(error_message))

if (nrow(errors) > 0) {
Expand All @@ -88,7 +88,7 @@ get_eahu <- function(year = 2010,
}

df <- df %>%
dplyr::select(-error)
dplyr::select(-any_of(c("error")))

if (!is.null(destfile) & !destfile_exists) {
saveRDS(df, file = destfile)
Expand All @@ -100,6 +100,6 @@ get_eahu <- function(year = 2010,
} else {
df %>%
tidyr::unnest(microdata) %>%
dplyr::select(-c(year, type))
dplyr::select(-any_of(c("year", "type")))
}
}
2 changes: 1 addition & 1 deletion R/get_eahu_internal.R
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ get_eahu_internal <- function(year = 2010,

base <- base %>%
dplyr::rename_all(toupper) %>%
dplyr::select(vars)
dplyr::select(all_of(vars))

return(base)
}
Expand Down
6 changes: 3 additions & 3 deletions R/get_microdata.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ get_microdata <- function(year = 2018,
dplyr::mutate(filter_col = purrr::map_lgl(error, ~ !is.null(.x))) %>%
dplyr::filter(filter_col) %>%
dplyr::mutate(error_message = purrr::map(error, ~ purrr::pluck(.x, 1))) %>%
dplyr::select(-microdata, -error) %>%
dplyr::select(-any_of(c("microdata", "error"))) %>%
tidyr::unnest(cols = c(error_message))

if (nrow(errors) > 0) {
Expand All @@ -109,7 +109,7 @@ get_microdata <- function(year = 2018,
}

df <- df %>%
dplyr::select(-error)
dplyr::select(-any_of(c("error")))

if (!is.null(destfile) & !destfile_exists) {
saveRDS(df, file = destfile)
Expand All @@ -121,6 +121,6 @@ get_microdata <- function(year = 2018,
} else {
df %>%
tidyr::unnest(microdata) %>%
dplyr::select(-c(year, period, type))
dplyr::select(-any_of(c("year", "period", "type")))
}
}
2 changes: 1 addition & 1 deletion R/get_microdata_internal.R
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ Mas informacon en: https://www.indec.gob.ar/ftp/cuadros/sociedad/anexo_informe_e

base %>%
dplyr::rename_all(toupper) %>%
dplyr::select(vars)
dplyr::select(all_of(vars))
} else {
base
}
Expand Down
6 changes: 3 additions & 3 deletions R/get_total_urbano.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ get_total_urbano <- function(year = 2016,
dplyr::mutate(filter_col = purrr::map_lgl(error, ~ !is.null(.x))) %>%
dplyr::filter(filter_col) %>%
dplyr::mutate(error_message = purrr::map(error, ~ purrr::pluck(.x, 1))) %>%
dplyr::select(-microdata, -error) %>%
dplyr::select(-any_of(c("microdata", "error"))) %>%
tidyr::unnest(cols = c(error_message))

if (nrow(errors) > 0) {
Expand All @@ -88,7 +88,7 @@ get_total_urbano <- function(year = 2016,
}

df <- df %>%
dplyr::select(-error)
dplyr::select(-any_of(c("error")))

if (!is.null(destfile) & !destfile_exists) {
saveRDS(df, file = destfile)
Expand All @@ -100,6 +100,6 @@ get_total_urbano <- function(year = 2016,
} else {
df %>%
tidyr::unnest(microdata) %>%
dplyr::select(-c(year, type))
dplyr::select(-any_of(c("year", "type")))
}
}
2 changes: 1 addition & 1 deletion R/get_total_urbano_internal.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ get_total_urbano_internal <- function(year = 2016,

base <- base %>%
dplyr::rename_all(toupper) %>%
dplyr::select(vars)
dplyr::select(all_of(vars))

return(base)
}
Expand Down
2 changes: 1 addition & 1 deletion R/organize_cno.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ organize_cno <- function(base) {
dplyr::left_join(., calificacion,
by = c("DIGIT5" = "value")
) %>%
dplyr::select(-c(CLASIF_CNO, DIGIT12, DIGIT3, DIGIT4, DIGIT5))
dplyr::select(-any_of(c("CLASIF_CNO", "DIGIT12", "DIGIT3", "DIGIT4", "DIGIT5")))



Expand Down
4 changes: 2 additions & 2 deletions R/organize_panels.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ organize_panels <- function(bases, variables, window = "anual") {
}

bases_continua <- dplyr::bind_rows(bases) %>%
dplyr::select(CODUSU, NRO_HOGAR, COMPONENTE,
ANO4, TRIMESTRE, CH04, CH06, variables) %>%
dplyr::select(all_of(c("CODUSU", "NRO_HOGAR", "COMPONENTE",
"ANO4", "TRIMESTRE", "CH04", "CH06", variables))) %>%
dplyr::filter(ESTADO != 0) %>%
dplyr::mutate(Periodo = zoo::as.yearqtr(paste0(ANO4, " Q", TRIMESTRE)))

Expand Down

0 comments on commit 88ab6ae

Please sign in to comment.