The “sidrar” R package seeks to provide direct access to the data of SIDRA - Sistema IBGE de Recuperação Automática - within the R environment in an easy and flexible way.
To install the version available on CRAN:
To install the development version hosted on Github:
For the time being, the “sidra” package contains only three functions:
library(sidrar)
get_sidra(x = 1419,
variable = 63,
period = c("last" = 12),
geo = "City",
geo.filter = 5002407,
classific = "c315",
category = list(7169),
header = FALSE,
format = 3)
For most users the data request is done via the online portal (https://sidra.ibge.gov.br). In this case, if you want to save the parameters of the table selected in the portal to a posterior request of the same table via sidrar, you should copy the path in the red rectangle and pass to the api argument in get_sidra:
In the previous examples we know how to recover data from tables according to the parameters reported. However, if I do not know what the parameters are, how should I proceed? To verify the parameters (variables, classifications, periods, etc.) of a given table, simply use the function “info_sidra”, informing the code of the table. The function returns a list with the possible parameters in the console. However, if wb = TRUE, the user can allow the result to be displayed in an web browser.
if wb = TRUE:
#> Can the web browser be open? (y/n):
By placing y, we have in this example: