-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathREADME.Rmd
117 lines (72 loc) · 5.29 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# Ibamam <img src="man/figures/hexlogo.png" align="right" width = "120px"/>
<!-- badges: start -->
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4509344.svg)](https://doi.org/10.5281/zenodo.4509344)
[![R-ubuntu](https://github.com/cccneto/Ibamam/actions/workflows/R-CMD-check-ubuntu.yaml/badge.svg)](https://github.com/cccneto/Ibamam/actions/workflows/R-CMD-check-ubuntu.yaml)
<!-- badges: end -->
This package aims to provide the dataset for environmental fines and notices from the Brazilian Institute for the Environment and Renewable Natural Resources (IBAMA).
You can visit the [IBAMA repository](https://dados.gov.br/organization/instituto-brasileiro-do-meio-ambiente-e-dos-recursos-naturais-renovaveis-ibama) in the [Brazilian Open Data Portal](https://dados.gov.br/).
## How to install?
This package can be installed via [GitHub](https://github.com/) using the following code in `R`:
``` r
# install.packages("remotes")
remotes::install_github("cccneto/Ibamam")
```
## How to use **Ibamam**?
The `{Ibamam}` package has one function available: `get_dataset_ibamam()`. This function returns a tibble, containing several columns [described in the documentation of the function](https://cccneto.github.io/Ibamam/reference/get_dataset_ibamam.html#value).
This function has three arguments: `dataset` , `uf` and `clean`.
- `dataset` can receive one of the two values: `distribuidas` or `arrecadadas`. Use `distribuidas` to get data of the environmental fines applied by Ibama. Use `arrecadadas` to get data of the environmental fines collected by Ibama (which means that the fine has been paid).
- `uf` is the abreviation of the name of the states (two letters in lower case) that data will be obtained. The default value is `"all"`, so all data from all the states of Brazil will be returned by default. Please notice that, If you use the default value, it might take several minutes to execute.
- `clean` is whether the dataset should be cleaned or not. If `TRUE`, the dataset will be cleaned. If `FALSE`, the returned dataset will be the original version, without modifications. Default is `TRUE`.
Examples on how to use this function:
```{r}
library(Ibamam)
# get fines applied by IBAMA in Pará
fines_applied_Para <- get_dataset_ibamam(dataset = "distribuidas", uf = "PA")
dplyr::glimpse(fines_applied_Para)
# get fines collected by IBAMA in Pará
fines_collected_Para <- get_dataset_ibamam(dataset = "arrecadadas", uf = "PA")
dplyr::glimpse(fines_collected_Para)
```
If you want to get the data for the whole country (Brazil), do not write anything in the argument uf.
```{r eval=FALSE, include=TRUE}
# get fines applied by IBAMA in Brazil
fines_applied_Brasil <- get_dataset_ibamam(dataset = "distribuidas")
# get fines collected by IBAMA in Brazil
fines_collected_Brasil <- get_dataset_ibamam(dataset = "arrecadadas")
```
If you want to get the data for more than one state, but not for the whole country, use a vector in the argument uf with the abbreviations of the name of the states.
```{r eval=FALSE, include=TRUE}
# get fines applied by IBAMA in Southeast of Brazil
fines_applied_southeast <- get_dataset_ibamam(dataset = "distribuidas", uf = c("SP", "RJ", "ES", "MG"))
# get fines collected by IBAMA in Southeast of Brazil
fines_collected_southeast <- get_dataset_ibamam(dataset = "arrecadadas", uf = c("SP", "RJ", "ES", "MG"))
```
If you want to access the original data, without the cleaning steps, use the argument `clean = FALSE`. Example:
```{r}
# get fines applied by IBAMA in São Paulo, without cleaning the dataset
untidy_fines_applied_SP <- get_dataset_ibamam(dataset = "distribuidas", uf = "SP", clean = FALSE)
dplyr::glimpse(untidy_fines_applied_SP)
```
<!-- Add cleaning steps here -->
## Data cleaning
By default, the function `get_dataset_ibamam()` will use `clean = TRUE` and perform the following cleaning steps:
- Colunms `dataAuto`, `ultimaAtualizacaoRelatorio`, `dataPagamento` are transformed from class `character` to class `date`.
- Colunms `tipoInfracao`, `tipoAuto`, `moeda`, `enquadramentoLegal` are transformed from class `character` to class `factor`.
- Column `enquadramentoJuridico` is created from the `cpfCnpj`: if `cpfCnpj` has 14 characteres or less, is "CPF", else is "CNPJ".
- Column `municipio` is mutated into `nomeMunicipio`, and several cleanings is made in order to be possible to join with the names of municipalities in the package `geobr`.
- Join the dataset with the result of the package `geobr`, so the cleaned dataset has a column with the IBGE code of the municipality, called `codigoMunicipio`.
If you want to access the original data (without the cleaning steps), use the argument `clean = FALSE`.
## How to cite Ibamam Package
[![DOI](<https://zenodo.org/badge/DOI/10.5281/zenodo.4509344.svg>)](<https://doi.org/10.5281/zenodo.4509344>) "**CRUZ NETO, Claudiano C., MILZ, Beatriz, MACEDO, Samuel** (2021). Ibamam: Pacote para tratamento da Base de dados para multas e autuações ambientais aplicadas pelo Instituto Brasileiro do Meio Ambiente e dos Recursos Naturais Renováveis - Brasil. <https://doi.org/10.5281/zenodo.4509344>".