Skip to content

Cambiar la fecha para la frecuencia, iniciaba en 2018 en lugar de 2006. #42

@JoseBurg

Description

@JoseBurg
get_imae <- function (variaciones = TRUE) {
  checkmate::assert_logical(variaciones)
  url <- paste0("https://cdn.bancentral.gov.do/", "documents/estadisticas/sector-real/documents/imae_2018.xlsx")
  temp_path <- base::tempfile(pattern = "", fileext = ".xlsx")
  utils::download.file(url, temp_path, quiet = TRUE, mode = "wb")
  header_imae <- c("mes", "indice_original", "original_vi", 
                   "origianl_va", "original_p12m", "indice_desestacionalizado", 
                   "desestacionalizado_vm", "desestacionalizado_vi", "desestacionalizado_va", 
                   "desestacionalizado_p12m", "indice_tc", "tc_vm", "tc_vi", 
                   "tc_va", "tc_p12m")
  suppressMessages(imae <- readxl::read_excel(path = temp_path, 
                                              skip = 8, col_names = FALSE))
  imae <- dplyr::select(dplyr::mutate(dplyr::filter(stats::setNames(janitor::remove_empty(dplyr::select(janitor::clean_names(imae), 
                                                                                                        -1), which = "cols"), header_imae), !is.na(mes)), 
                                      fecha = seq(as.Date("2006-01-01"), by = "month", length.out = dplyr::n()), 
                                      year = lubridate::year(fecha)), 
                        fecha, year, mes, dplyr::everything())
  if (!variaciones) {
    imae <- dplyr::select(imae, fecha, year, mes, dplyr::contains("indice"))
  }
  imae
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions