View source: R/datasus_catalog.R
| datasus_get_territory | R Documentation |
Downloads and reads tables from the DATASUS territorial data section. The DATASUS FTP publishes a ZIP archive per year containing reference tables for municipalities, health regions, and other geographic divisions used by SUS, in CSV, DBF, and TXT formats.
datasus_get_territory(
table = "tb_municip",
year = NULL,
format = "csv",
cache_dir = NULL,
verbose = TRUE
)
table |
Name of the table to read. Common values:
|
year |
Year of the territorial table. Defaults to the current year.
Use |
format |
File format to extract from the ZIP: |
cache_dir |
Optional cache directory. |
verbose |
Logical. Emit progress messages (default |
A tibble with column names in snake_case.
tryCatch({
# Download territorial tables into tempdir() (network required).
municipios <- datasus_get_territory(
"tb_municip",
cache_dir = tempdir(),
verbose = FALSE
)
ufs <- datasus_get_territory(
"tb_uf",
cache_dir = tempdir(),
verbose = FALSE
)
}, error = function(e) message("FTP unavailable: ", conditionMessage(e)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.