knitr::opts_chunk$set(echo = TRUE, collapse = TRUE, comment = "#>")
library(magrittr) library(stringr) library(dplyr)
The "datasus" R package seeks to provide direct access to the data of TABNET/DATASUS within the R environment much in the same way that is done in the online portal. For now the package allows access to the systematic record of mortality and survival data (Vital Statistics - Mortality and Live Births) through SIM and SINASC's systems
To install the development version hosted on Github:
library(devtools) install_github("rpradosiqueira/datasus")
The functions are named by parts:
Then, for example we have:
sinasc_nv_uf Scrapes SINASC data from the states unities sinasc_nv_mun Scrapes SINASC data from municipalities sinasc_nv_bruf Scrapes SINASC data from regions sim_obt10_uf Scrapes SIM ICD-10 data from the states unities sim_obt10_mun Scrapes SIM ICD-10 data from cities sim_obt10_bruf Scrapes SIM ICD-10 data from regions
1) Let's assume that we want the live births for the cities of the state of Mato Grosso do Sul. However, we will only recover the last five years and we want the cities to be in the rows and the years in the columns. To do this simply execute:
library(datasus) sinasc_nv_uf(uf = "ms", periodo = c(2011:2015), coluna = "Ano do nascimento")
## Tabela obtida library(datasus) sinasc_nv_uf(uf = "ms", periodo = c(2011:2015), coluna = "Ano do nascimento")
2) In this example we will download the last mortality data for the IBGE's micro-region where the micro-regions are in the rows and the ICD-10 chapters in the columns (only 10 rows):
sim_obt10_mun(linha = "Microrregião IBGE", coluna = "Capítulo CID-10")
head(sim_obt10_mun(linha = "Microrregião IBGE", coluna = "Capítulo CID-10"))
The argument's input is written in the same way that is done in the online portal or in some cases it can be the order of the input according to the online layout.
Online access for mortality data by municipality:
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.