| caged_load | R Documentation |
Combina caged_download(), caged_parse() e caged_to_duckdb()
em um único comando. É o jeito mais simples de popular o banco local.
caged_load(
years,
months = seq_len(12L),
states = NULL,
db_path = file.path(tempdir(), "caged.duckdb"),
destdir = NULL,
force_download = FALSE,
overwrite_competencies = FALSE,
timeout = 300,
workers = getOption("datacaged.workers", min(3L, future::availableCores()))
)
years |
integer vector. Desired years. |
months |
integer vector. Desired months (1–12). Default: |
states |
character vector or NULL. Ignored — the parameter is validated but does not filter downloads for any series (Novo CAGED, antigo or Ajustes), as all files are national in scope. Kept for backwards compatibility. |
db_path |
character. Path to the file |
destdir |
character or NULL. Cache directory for |
force_download |
logical. Re-downloads files already in cache. Default: FALSE. |
overwrite_competencies |
logical. Overwrites competencies already in the database. Default: FALSE. |
timeout |
integer. Timeout per file in seconds. Default: 300. |
workers |
integer. Number of parallel downloads. Default: 3.
Use |
invisible: tibble with final database statistics (via caged_info()).
caged_adjustments_load() para o CAGED Ajustes (correções retroativas até 2019).
caged_download() para baixar sem gravar no banco.
caged_info() para inspecionar o banco após a carga.
## Not run:
# Download real --- exemplos nao executados automaticamente (requerem rede e tempo)
# Novo CAGED: 1 mes recente
caged_load(
years = 2024,
months = 1,
db_path = file.path(tempdir(), "caged.duckdb")
)
# CAGED antigo: 1 ano
caged_load(
years = 2019,
months = seq_len(12L),
db_path = file.path(tempdir(), "caged_historico.duckdb")
)
# Conecta e consulta
con <- caged_connect(file.path(tempdir(), "caged.duckdb"))
if ("caged_mov" %in% DBI::dbListTables(con)) {
dplyr::tbl(con, "caged_mov") |>
dplyr::group_by(competencia, uf) |>
dplyr::summarise(saldo = sum(saldomovimentacao, na.rm = TRUE)) |>
dplyr::collect()
}
DBI::dbDisconnect(con, shutdown = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.