| microdados_ler | R Documentation |
Downloads the requested DBC files and reads them directly in memory using the native 'datasusr' decoder. Column selection and 'n_max' are applied during parsing, which is useful for large SIH files.
microdados_ler(
sistema,
tipo = NULL,
ano,
mes = NULL,
uf = NULL,
destino = NULL,
cache = TRUE,
atualizar = FALSE,
preliminares = TRUE,
verificar = TRUE,
timeout = 240,
colunas = NULL,
n_max = Inf,
normalizar = FALSE,
juntar = TRUE,
...
)
sistema |
System: '"sim"', '"sinasc"' or '"sih"'. |
tipo |
File type returned by [microdados_catalogo()]. 'NULL' selects the default type for the system. |
ano |
One or more four-digit years. |
mes |
One or more months from 1 to 12. Required for SIH. |
uf |
One or more state abbreviations, two-digit IBGE codes or state names. Required for UF-scoped types. |
destino |
Optional destination directory. 'NULL' uses the package cache, or a session temporary directory when 'cache = FALSE'. |
cache |
Whether to reuse the disk cache. |
atualizar |
Whether to request a fresh copy of already cached files. |
preliminares |
Whether preliminary directories may be considered. |
verificar |
Whether to verify file existence on the DATASUS server. |
timeout |
Network timeout in seconds for file discovery. |
colunas |
Optional vector of original or lower-case columns to read. |
n_max |
Maximum number of records to read from each file. |
normalizar |
Whether to rename and type common fields with [datasus_padronizar()]. |
juntar |
Whether to combine multiple files. If 'FALSE', returns a named list. |
... |
Additional arguments passed to [datasusr::read_datasus_dbc()]. |
A data frame, or a named list when 'juntar = FALSE', with provenance metadata attached.
old_options <- options(
datasus.timeout = 5,
datasus.download_timeout = 15,
datasus.max_tries = 1
)
try({
admissions <- microdados_ler(
"sih",
ano = 2024,
mes = 1,
uf = "AC",
colunas = c("MUNIC_RES", "DT_INTER", "DIAG_PRINC", "VAL_TOT"),
n_max = 1000,
normalizar = TRUE
)
})
options(old_options)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.