---
title: "Índice de transparência - DadosJusBr"
lang: pt-BR
format:
html:
html-math-method: katex
css: style.css
anchor-sections: true
code-fold: true
code-tools: true
code-link: true
code-line-numbers: true
code-summary: "Código"
toc: true
toc-title: "Índice"
toc-depth: 4
toc-float: false
toc-collapsed: false
footnotes-hover: true
smooth-scroll: true
fig-width: 10
fig-height: 7
search: true
theme:
light: flatly
dark: darkly
knitr:
opts_chunk:
echo: false
collapse: true
message: false
warning: false
comment: "#>"
editor_options:
chunk_output_type: console
execute:
cache: false
---
```{r}
#| label: libs-e-setup
library (tidyverse)
library (lubridate)
library (jsonlite)
library (scales)
library (extrafont)
library (here)
library (gt)
source (here ("src/00-plot-aesthetics.R" ), encoding = "utf-8" )
#source(here("src/01-indices-e-pesos.R"), encoding = "utf-8")
# carregando os dados em disco
indices <- "data/load" %>%
here () %>%
list.files (pattern = "indices-2022- \\ d{2}- \\ d{2}" , full.names = TRUE ) %>%
file.info () %>%
rownames_to_column (var = "file" ) %>%
filter (ctime == max (ctime)) %>%
pull (file) %>%
readRDS ()
```
## Distribuição dos Pesos
```{r}
#| label: tbl-pesos
gsheet <- "1xEx525Dxnk0BtS4-3f2SM9vHQr_tMXXY3maUIKnfYfk"
gsheet <- googlesheets4:: read_sheet (gsheet)
wgt_table <- function (df, criterio) {
df %>%
filter (Critério == criterio) %>%
select (- Critério) %>%
group_by (Dimensão, Descrição) %>%
gt (
# groupname_col = "Dimensão",
# rowname_col = "Descrição"
) %>%
tab_options (
row_group.as_column = T,
column_labels.font.weight = "bold" ,
table_body.border.bottom.color = "black" ,
table_body.border.top.color = "black" ,
grand_summary_row.border.color = "black" ,
heading.border.bottom.color = "black" ,
table.border.top.color = "black" ,
column_labels.border.top.color = "black" ,
column_labels.border.bottom.color = "black" ,
stub_row_group.font.size = 12 ,
stub_row_group.font.weight = "bold"
) %>%
tab_style (
style = list (
cell_text (
font = "Fira Code" ,
size = "x-small" ,
color = "darkred" ,
weight = "bold"
)
),
locations = cells_body (Label)
) %>%
tab_style (
style = cell_text (
size = "small" ,
),
locations = cells_body (Item)
) %>%
tab_style (
style = cell_borders (
sides = c ("bottom" , "top" ),
color = "black"
),
locations = list (
cells_row_groups (everything ()),
cells_body (
columns = everything (),
rows = everything ()
)
)
) %>%
cols_width (
Item ~ pct (30 ),
Label ~ pct (30 ),
Peso ~ pct (30 )
) %>%
tab_style (
style = cell_fill (color = cores_dadosjusbr[["cinza_claro" ]]),
locations = cells_body (Peso)
) %>%
tab_style (
style = cell_fill (color = 'white' ),
locations = cells_body (
columns = Peso,
rows = Item == "Órgão não prestou contas"
)
)
}
```
:::{.column-body-outset}
### Critérios de Facilidade
```{r}
#| label: wgt-table-facilidade
#| panel: fill
wgt_table (gsheet, "Facilidade" )
```
### Critérios de Completude
```{r}
#| label: wgt-table-completude
#| panel: fill
wgt_table (gsheet, "Completude" )
```
:::
```{r}
#| label: plot-categoria
plot_categoria <- function (df, orgao, categoria, pallete) {
df <- df %>% filter (aid %in% orgao)
plot_title <- str_glue ("{itens_categoria[[categoria]]} | {unique(df$subgrupo)}" )
df %>%
filter (! periodo_invalido) %>%
ggplot (aes_string (x = "data" , y = "aid" , fill = categoria)) +
facet_wrap (ano ~ ., nrow = 1 , scales = "free_x" ) +
geom_tile (color = "gray90" ) +
geom_tile (
data = . %>% filter (periodo_invalido),
fill = cores_dadosjusbr[["cinza_claro" ]],
color = "gray90"
) +
scale_fill_manual (values = pallete) +
scale_x_date (
date_breaks = "3 months" ,
date_labels = "%b"
) +
theme_adjust_waffle +
labs (
x = "Cada célula representa 1 mês" ,
y = NULL ,
title = plot_title,
fill = NULL
) +
guides (fill = guide_legend (nrow = 1 )) +
scale_y_discrete (expand = c (0 , 0 )) +
theme (axis.title.x = element_text (face = "italic" ))
}
```
```{r}
#| label: vetor-de-orgaos-por-subgrupo
#| echo: false
#| warning: false
#| message: false
indices %>%
distinct (aid, subgrupo) %>%
group_by (subgrupo) %>%
nest () %>%
deframe () %>%
map (pull) %>%
list2env (., .GlobalEnv) %>%
invisible ()
```
## Índice de Facilidade
### Acesso
- Acesso direto (`ACESSO_DIRETO` & `AMIGAVEL_PARA_RASPAGEM` )
- Raspagem dificultada (`RASPAGEM_DIFICULTADA` )
- Necessita simulação de usuário (`NECESSITA_SIMULACAO_USUARIO` )
- Órgão não prestou contas (`NA` )
::: {.panel-tabset}
#### MP
```{r}
#| label: plot-mp-acesso
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, acesso_wgt, sum)) %>%
plot_categoria (
orgao = ` Ministérios Públicos estaduais ` ,
categoria = "acesso" ,
pallete = cores_acesso
)
```
#### Tj
```{r}
#| label: plot-tj-acesso
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, acesso_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais de Justiça estaduais ` ,
categoria = "acesso" ,
pallete = cores_acesso
)
```
#### TRF
```{r}
#| label: plot-trf-acesso
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, acesso_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais Regionais Federais ` ,
categoria = "acesso" ,
pallete = cores_acesso
)
```
#### TRT
```{r}
#| label: plot-trt-acesso
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, acesso_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais Regionais do Trabalho ` ,
categoria = "acesso" ,
pallete = cores_acesso
)
```
#### TJM
```{r}
#| label: plot-tjm-acesso
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, acesso_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais de Justiça Militar ` ,
categoria = "acesso" ,
pallete = cores_acesso
)
```
#### Órgãos superiores
```{r}
#| label: plot-superiores-acesso
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, acesso_wgt, sum)) %>%
plot_categoria (
orgao = ` Órgãos superiores ` ,
categoria = "acesso" ,
pallete = cores_acesso
)
```
:::
### Manteve consistência no formato
- Manteve consistência no formato (`TRUE` )
- Não manteve consistência no formato (`FALSE` )
- Órgão não prestou contas (`NA` )
::: {.panel-tabset}
#### MP
```{r}
#| label: plot-mp-manteve-consistencia
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, manteve_consistencia_no_formato_wgt, sum)) %>%
plot_categoria (
orgao = ` Ministérios Públicos estaduais ` ,
categoria = "manteve_consistencia_no_formato" ,
pallete = cores_manteve_consistencia_no_formato
)
```
#### TJ
```{r}
#| label: plot-tj-manteve-consistencia
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, manteve_consistencia_no_formato_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais de Justiça estaduais ` ,
categoria = "manteve_consistencia_no_formato" ,
pallete = cores_manteve_consistencia_no_formato
)
```
#### TRF
```{r}
#| label: plot-trf-manteve-consistencia
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, manteve_consistencia_no_formato_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais Regionais Federais ` ,
categoria = "manteve_consistencia_no_formato" ,
pallete = cores_manteve_consistencia_no_formato
)
```
#### TRT
```{r}
#| label: plot-trt-manteve-consistencia
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, manteve_consistencia_no_formato_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais Regionais do Trabalho ` ,
categoria = "manteve_consistencia_no_formato" ,
pallete = cores_manteve_consistencia_no_formato
)
```
#### TJM
```{r}
#| label: plot-tjm-manteve-consistencia
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, manteve_consistencia_no_formato_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais de Justiça Militar ` ,
categoria = "manteve_consistencia_no_formato" ,
pallete = cores_manteve_consistencia_no_formato
)
```
#### Órgãos superiores
```{r}
#| label: plot-superiores-manteve-consistencia
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, manteve_consistencia_no_formato_wgt, sum)) %>%
plot_categoria (
orgao = ` Órgãos superiores ` ,
categoria = "manteve_consistencia_no_formato" ,
pallete = cores_manteve_consistencia_no_formato
)
```
:::
### Dados Estritamente Tabulares
- Dados estritamente tabulares (`TRUE` )
- Dados não tabulares (`FALSE` )
- Órgão não prestou contas (`NA` )
::: {.panel-tabset}
#### MP
```{r}
#| label: plot-mp-tabulares
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, dados_estritamente_tabulares_wgt, sum)) %>%
plot_categoria (
orgao = ` Ministérios Públicos estaduais ` ,
categoria = "dados_estritamente_tabulares" ,
pallete = cores_dados_estritamente_tabulares
)
```
#### TJ
```{r}
#| label: plot-tj-tabulares
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, dados_estritamente_tabulares_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais de Justiça estaduais ` ,
categoria = "dados_estritamente_tabulares" ,
pallete = cores_dados_estritamente_tabulares
)
```
#### TRF
```{r}
#| label: plot-trf-tabulares
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, dados_estritamente_tabulares_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais Regionais Federais ` ,
categoria = "dados_estritamente_tabulares" ,
pallete = cores_dados_estritamente_tabulares
)
```
#### TRT
```{r}
#| label: plot-trt-tabulares
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, dados_estritamente_tabulares_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais Regionais do Trabalho ` ,
categoria = "dados_estritamente_tabulares" ,
pallete = cores_dados_estritamente_tabulares
)
```
#### TJM
```{r}
#| label: plot-tjm-extensao
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, extensao_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais de Justiça Militar ` ,
categoria = "extensao" ,
pallete = cores_extensao
)
```
#### Órgãos superiores
```{r}
#| label: plot-superiores-tabulares
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, dados_estritamente_tabulares_wgt, sum)) %>%
plot_categoria (
orgao = ` Órgãos superiores ` ,
categoria = "dados_estritamente_tabulares" ,
pallete = cores_dados_estritamente_tabulares
)
```
:::
### Possui formato aberto
#### Extensão
- CSV (`Formato Proprietário` )
- HTML (`Formato Aberto` )
- ODS (`Formato Aberto` )
- XLS (`Formato Proprietário` )
- Órgão não prestou contas (`NA` )
::: {.panel-tabset}
##### MP
```{r}
#| label: plot-mp-extensao
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, extensao_wgt, sum)) %>%
plot_categoria (
orgao = ` Ministérios Públicos estaduais ` ,
categoria = "extensao" ,
pallete = cores_extensao
)
```
##### TJ
```{r}
#| label: plot-tj-extensao
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, extensao_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais de Justiça estaduais ` ,
categoria = "extensao" ,
pallete = cores_extensao
)
```
##### TRF
```{r}
#| label: plot-trf-extensao
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, extensao_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais Regionais Federais ` ,
categoria = "extensao" ,
pallete = cores_extensao
)
```
##### TRT
```{r}
#| label: plot-trt-extensao
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, extensao_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais Regionais do Trabalho ` ,
categoria = "extensao" ,
pallete = cores_extensao
)
```
##### Órgãos superiores
```{r}
#| label: plot-superiores-extensao
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, extensao_wgt, sum)) %>%
plot_categoria (
orgao = ` Órgãos superiores ` ,
categoria = "extensao" ,
pallete = cores_extensao
)
```
:::
#### Formato Aberto ou Proprietário
- Formato aberto (`ODS, HTML` )
- Formato Proprietário (`XLS, CSV` )
- Órgão não prestou contas (`NA` )
::: {.panel-tabset}
##### MP
```{r}
#| label: plot-mp-formato-aberto
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, formato_aberto_wgt, sum)) %>%
plot_categoria (
orgao = ` Ministérios Públicos estaduais ` ,
categoria = "formato_aberto" ,
pallete = cores_formato_aberto
)
```
##### TJ
```{r}
#| label: plot-tj-formato-aberto
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, formato_aberto_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais de Justiça estaduais ` ,
categoria = "formato_aberto" ,
pallete = cores_formato_aberto
)
```
##### TRF
```{r}
#| label: plot-trf-formato-aberto
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, formato_aberto_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais Regionais Federais ` ,
categoria = "formato_aberto" ,
pallete = cores_formato_aberto
)
```
##### TRT
```{r}
#| label: plot-trt-formato-aberto
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, formato_aberto_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais Regionais do Trabalho ` ,
categoria = "formato_aberto" ,
pallete = cores_formato_aberto
)
```
##### Órgãos superiores
```{r}
#| label: plot-superiores-formato-aberto
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, formato_aberto_wgt, sum)) %>%
plot_categoria (
orgao = ` Órgãos superiores ` ,
categoria = "formato_aberto" ,
pallete = cores_formato_aberto
)
```
:::
## Índice de Completude
### Possui Nome e Matrícula
- Possui nome e matrícula (`TRUE` )
- Não possui lotação (`FALSE` )
- Órgão não prestou contas (`NA` )
::: {.panel-tabset}
#### MP
```{r}
#| label: plot-mp-tem-nome-matricula
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, tem_matricula_wgt, sum)) %>%
plot_categoria (
orgao = ` Ministérios Públicos estaduais ` ,
categoria = "tem_matricula" ,
pallete = cores_tem_matricula
)
```
#### TJ
```{r}
#| label: plot-tj-tem-nome-matricula
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, tem_matricula_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais de Justiça estaduais ` ,
categoria = "tem_matricula" ,
pallete = cores_tem_matricula
)
```
#### TRF
```{r}
#| label: plot-trf-tem-nome-matricula
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, tem_matricula_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais Regionais Federais ` ,
categoria = "tem_matricula" ,
pallete = cores_tem_matricula
)
```
#### TRT
```{r}
#| label: plot-trt-tem-nome-matricula
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, tem_matricula_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais Regionais do Trabalho ` ,
categoria = "tem_matricula" ,
pallete = cores_tem_matricula
)
```
#### TJM
```{r}
#| label: plot-tjm-nome-matricula
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, tem_matricula_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais de Justiça Militar ` ,
categoria = "tem_matricula" ,
pallete = cores_tem_matricula
)
```
#### Órgãos superiores
```{r}
#| label: plot-superiores-nome-matricula
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, tem_matricula_wgt, sum)) %>%
plot_categoria (
orgao = ` Órgãos superiores ` ,
categoria = "tem_matricula" ,
pallete = cores_tem_matricula
)
```
:::
### Possui Lotação
- Possui lotação (`TRUE` )
- Não possui lotação (`FALSE` )
- Órgão não prestou contas (`NA` )
::: {.panel-tabset}
#### MP
```{r}
#| label: plot-mp-tem-lotacao
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, tem_lotacao_wgt, sum)) %>%
plot_categoria (
orgao = ` Ministérios Públicos estaduais ` ,
categoria = "tem_lotacao" ,
pallete = cores_tem_lotacao
)
```
#### TJ
```{r}
#| label: plot-tj-tem-lotacao
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, tem_lotacao_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais de Justiça estaduais ` ,
categoria = "tem_lotacao" ,
pallete = cores_tem_lotacao
)
```
#### TRF
```{r}
#| label: plot-trf-tem-lotacao
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, tem_lotacao_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais Regionais Federais ` ,
categoria = "tem_lotacao" ,
pallete = cores_tem_lotacao
)
```
#### TRT
```{r}
#| label: plot-trt-tem-lotacao
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, tem_lotacao_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais Regionais do Trabalho ` ,
categoria = "tem_lotacao" ,
pallete = cores_tem_lotacao
)
```
#### TJM
```{r}
#| label: plot-tjm-tem-lotacao
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, tem_lotacao_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais de Justiça Militar ` ,
categoria = "tem_lotacao" ,
pallete = cores_tem_lotacao
)
```
#### Órgãos superiores
```{r}
#| label: plot-superiores-tem-lotacao
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, tem_lotacao_wgt, sum)) %>%
plot_categoria (
orgao = ` Órgãos superiores ` ,
categoria = "tem_lotacao" ,
pallete = cores_tem_lotacao
)
```
:::
### Possui Cargo
- Possui cargo (`TRUE` )
- Não possui cargo (`FALSE` )
- Órgão não prestou contas (`NA` )
::: {.panel-tabset}
#### MP
```{r}
#| label: plot-mp-tem-cargo
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, tem_cargo_wgt, sum)) %>%
plot_categoria (
orgao = ` Ministérios Públicos estaduais ` ,
categoria = "tem_cargo" ,
pallete = cores_tem_cargo
)
```
#### TJ
```{r}
#| label: plot-tj-tem-cargo
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, tem_cargo_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais de Justiça estaduais ` ,
categoria = "tem_cargo" ,
pallete = cores_tem_cargo
)
```
#### TRF
```{r}
#| label: plot-trf-tem-cargo
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, tem_cargo_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais Regionais Federais ` ,
categoria = "tem_cargo" ,
pallete = cores_tem_cargo
)
```
#### TRT
```{r}
#| label: plot-trt-tem-cargo
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, tem_cargo_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais Regionais do Trabalho ` ,
categoria = "tem_cargo" ,
pallete = cores_tem_cargo
)
```
#### TJM
```{r}
#| label: plot-tjm-tem-cargo
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, tem_cargo_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais de Justiça Militar ` ,
categoria = "tem_cargo" ,
pallete = cores_tem_cargo
)
```
#### Órgãos superiores
```{r}
#| label: plot-superiores-tem-cargo
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, tem_cargo_wgt, sum)) %>%
plot_categoria (
orgao = ` Órgãos superiores ` ,
categoria = "tem_cargo" ,
pallete = cores_tem_cargo
)
```
:::
### Remuneração básica
- Dados detalhados (`DETALHADO` )
- Dados sumarizados (`SUMARIZADO` )
- Dados ausentes (`AUSENTE` )
- Órgão não presou contas (`NA` )
::: {.panel-tabset}
#### MP
```{r}
#| label: plot-mp-remuneracao-basica
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, remuneracao_basica_wgt, sum)) %>%
plot_categoria (
orgao = ` Ministérios Públicos estaduais ` ,
categoria = "remuneracao_basica" ,
pallete = cores_remuneracoes
)
```
#### TJ
```{r}
#| label: plot-tj-remuneracao-basica
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, remuneracao_basica_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais de Justiça estaduais ` ,
categoria = "remuneracao_basica" ,
pallete = cores_remuneracoes
)
```
#### TRF
```{r}
#| label: plot-trf-remuneracao-basica
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, remuneracao_basica_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais Regionais Federais ` ,
categoria = "remuneracao_basica" ,
pallete = cores_remuneracoes
)
```
#### TRT
```{r}
#| label: plot-trt-remuneracao-basica
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, remuneracao_basica_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais Regionais do Trabalho ` ,
categoria = "remuneracao_basica" ,
pallete = cores_remuneracoes
)
```
#### TJM
```{r}
#| label: plot-tjm-remuneracao-basica
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, remuneracao_basica_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais de Justiça Militar ` ,
categoria = "remuneracao_basica" ,
pallete = cores_remuneracoes
)
```
#### Órgãos superiores
```{r}
#| label: plot-superiores-remuneracao-basica
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, remuneracao_basica_wgt, sum)) %>%
plot_categoria (
orgao = ` Órgãos superiores ` ,
categoria = "remuneracao_basica" ,
pallete = cores_remuneracoes
)
```
:::
### Despesas
- Dados detalhados (`DETALHADO` )
- Dados sumarizados (`SUMARIZADO` )
- Dados ausentes (`AUSENTE` )
- Órgão não presou contas (`NA` )
::: {.panel-tabset}
#### MP
```{r}
#| label: plot-mp-despesas
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, despesas_wgt, sum)) %>%
plot_categoria (
orgao = ` Ministérios Públicos estaduais ` ,
categoria = "despesas" ,
pallete = cores_remuneracoes
)
```
#### TJ
```{r}
#| label: plot-tj-despesas
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, despesas_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais de Justiça estaduais ` ,
categoria = "despesas" ,
pallete = cores_remuneracoes
)
```
#### TRF
```{r}
#| label: plot-trf-despesas
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, despesas_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais Regionais Federais ` ,
categoria = "despesas" ,
pallete = cores_remuneracoes
)
```
#### TRT
```{r}
#| label: plot-trt-despesas
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, despesas_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais Regionais do Trabalho ` ,
categoria = "despesas" ,
pallete = cores_remuneracoes
)
```
#### TJM
```{r}
#| label: plot-tjm-despesas
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, despesas_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais de Justiça Militar ` ,
categoria = "despesas" ,
pallete = cores_remuneracoes
)
```
#### Órgãos superiores
```{r}
#| label: plot-superiores-despesas
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, despesas_wgt, sum)) %>%
plot_categoria (
orgao = ` Órgãos superiores ` ,
categoria = "despesas" ,
pallete = cores_remuneracoes
)
```
:::
### Outras Receitas
- Dados detalhados (`DETALHADO` )
- Dados sumarizados (`SUMARIZADO` )
- Dados ausentes (`AUSENTE` )
- Órgão não presou contas (`NA` )
::: {.panel-tabset}
#### MP
```{r}
#| label: plot-mp-outras-receitas
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, outras_receitas_wgt, sum)) %>%
plot_categoria (
orgao = ` Ministérios Públicos estaduais ` ,
categoria = "outras_receitas" ,
pallete = cores_remuneracoes
)
```
#### TJ
```{r}
#| label: plot-tj-outras-receitas
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, outras_receitas_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais de Justiça estaduais ` ,
categoria = "outras_receitas" ,
pallete = cores_remuneracoes
)
```
#### TRF
```{r}
#| label: plot-trf-outras-receitas
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, outras_receitas_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais Regionais Federais ` ,
categoria = "outras_receitas" ,
pallete = cores_remuneracoes
)
```
#### TRT
```{r}
#| label: plot-trt-outras-receitas
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, outras_receitas_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais Regionais do Trabalho ` ,
categoria = "outras_receitas" ,
pallete = cores_remuneracoes
)
```
#### TJM
```{r}
#| label: plot-tjm-outras-receitas
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, outras_receitas_wgt, sum)) %>%
plot_categoria (
orgao = ` Tribunais de Justiça Militar ` ,
categoria = "outras_receitas" ,
pallete = cores_remuneracoes
)
```
#### Órgãos superiores
```{r}
#| label: plot-superiores-outras-receitas
#| echo: false
#| warning: false
#| message: false
indices %>%
mutate (aid = reorder (aid, outras_receitas_wgt, sum)) %>%
plot_categoria (
orgao = ` Órgãos superiores ` ,
categoria = "outras_receitas" ,
pallete = cores_remuneracoes
)
```
:::
## Índice de Transparência
:::{.column-body-outset}
### Facilidade
$$
\begin{aligned}
Índice\;de\;Facilidade = \frac{(Acesso_{mês} + Manteve\;consistência\;no\;formato_ {mês} +\\ Dados\;estritamente\;tabulares_{mês} + Formato\;aberto_{mês})}{4}
\end{aligned}
$$
### Completude
$$
\begin{aligned}
Índice\;de\;Completude = \frac{(Possui\;nome\;e\;matrícula_{mês} + Possui\;lotacão + possui\;cargo + \\ Remuneracão\;básica_{mês} + Despesas_{mês} + Outras\;receitas_{mês})}{6}
\end{aligned}
$$
$$
Índice\;de\;Transparência = 2 \times \frac{Índice\;Facilidade_{mês} \times Índice\;Completude_{mês}}{Índice\;Facilidade_{mês} + Índice\;Completude_{mês}}
$$
:::
### Visualização do índice
#### Ministérios Públicos
```{r}
criterios <- c ("Tem cargo" , "Tem lotação" , "Tem matrícula" , "Remuneração básica" , "Outras receitas" , "Despesas" )
indices_long <- indices %>%
filter (! periodo_invalido) %>%
select (
mes, ano, aid, subgrupo, data, periodo_invalido,
ends_with ("_wgt" ),
- extensao_wgt
) %>%
pivot_longer (
- c (mes, ano, data, periodo_invalido, aid, subgrupo),
names_to = "criterio" , values_to = "pontuacao"
) %>%
mutate (
criterio = case_when (
criterio == "acesso_wgt" ~ "Acesso" ,
criterio == "manteve_consistencia_no_formato_wgt" ~ "Manteve consistência no formato" ,
criterio == "dados_estritamente_tabulares_wgt" ~ "Dados estritamente tabulares" ,
criterio == "extensao_wgt" ~ "Extensão" ,
criterio == "formato_aberto_wgt" ~ "Formato aberto" ,
criterio == "tem_matricula_wgt" ~ "Tem matrícula" ,
criterio == "tem_cargo_wgt" ~ "Tem cargo" ,
criterio == "tem_lotacao_wgt" ~ "Tem lotação" ,
criterio == "remuneracao_basica_wgt" ~ "Remuneração básica" ,
criterio == "despesas_wgt" ~ "Despesas" ,
criterio == "outras_receitas_wgt" ~ "Outras receitas" ,
TRUE ~ criterio
),
pontuacao = case_when (
subgrupo %in% c ("Tribunais de Justiça estaduais" ,
"Tribunais Regionais Federais" ,
"Tribunais Regionais do Trabalho" ,
"Tribunais de Justiça Militar" ) &
criterio == "Acesso" & pontuacao == - 1 ~ 0 ,
subgrupo %in% c ("Tribunais de Justiça estaduais" ,
"Tribunais Regionais Federais" ,
"Tribunais Regionais do Trabalho" ,
"Tribunais de Justiça Militar" ) &
criterio == "Extensão" & pontuacao == - 1 ~ 0 ,
subgrupo %in% c ("Tribunais de Justiça estaduais" ,
"Tribunais Regionais Federais" ,
"Tribunais Regionais do Trabalho" ,
"Tribunais de Justiça Militar" ) &
criterio == "Manteve consistência no formato" &
pontuacao == - 1 ~ 1 ,
subgrupo %in% c ("Tribunais de Justiça estaduais" ,
"Tribunais Regionais Federais" ,
"Tribunais Regionais do Trabalho" ,
"Tribunais de Justiça Militar" ) &
criterio == "Dados estritamente tabulares" &
pontuacao == - 1 ~ 1 ,
aid == "STJ" &
criterio == "Dados estritamente tabulares" &
pontuacao == - 1 ~ 1 ,
TRUE ~ pontuacao
),
pontuacao = if_else (pontuacao < 0 , 0 , pontuacao),
dimensao = if_else (criterio %in% criterios, "Completude" , "Facilidade" )
)
# Função que faz o cálculo da média harmônica em `indice`
media_harmonica <- function (x,y) if_else (x + y == 0 , 0 , ((x * y) / (x + y)) * 2 )
# `indice_pontuacoes` contém os índices de Completude, Facilidade e Transparência
indices_pontuacoes <- indices_long %>%
filter (! periodo_invalido) %>%
group_by (mes, ano, aid, subgrupo, dimensao) %>%
summarise (indice = mean (pontuacao), .groups = "drop" ) %>%
pivot_wider (names_from = dimensao, values_from = indice) %>%
mutate (Transparência = media_harmonica (Completude, Facilidade))
```
```{r}
#| label: indice-media-geral
# `indice_media_geral`: média aritmética simples dos índices de todo o período
indices_media_geral <- indices_pontuacoes %>%
group_by (aid, subgrupo) %>%
summarise (across (c (Completude, Facilidade, Transparência), mean), .groups = "drop" ) %>%
mutate (
across (
.cols = where (is.double),
.fns = ~ if_else (Completude + Facilidade + Transparência == 0 , - 1 , .)
))
```
```{r}
#| fig-height: 9
plot_indice <- function (df, aid_cut, subgroup, box_center, max_limit) {
cut_orgao <- df %>%
pivot_longer (- c (aid, subgrupo), names_to = "dimensao" , values_to = "pontuacao" ) %>%
mutate (aid = reorder (aid, pontuacao, sum)) %>%
filter (dimensao == "Transparência" , aid == aid_cut) %>%
mutate (
center = box_center,
lbl = str_glue (" índice de \n Transparência é uma \n média harmônica \n das pontuações \n obtidas nas dimensões \n Completude e Facilidade" )
)
indices_media_geral %>%
filter (subgrupo %in% subgroup) %>%
pivot_longer (- c (aid, subgrupo), names_to = "dimensao" , values_to = "pontuacao" ) %>%
mutate (aid_wgt = if_else (dimensao == "Transparência" , pontuacao, NA_real_ )) %>%
group_by (aid) %>%
fill (aid_wgt, .direction = "up" ) %>%
ungroup () %>%
mutate (aid = reorder (aid, aid_wgt)) %>%
ggplot (aes (
y = aid,
x = pontuacao
)) +
geom_line (color = cores_dadosjusbr[["cinza_azulado" ]]) +
geom_point (
data = . %>% filter (dimensao != "Transparência" ),
aes (fill = dimensao, size = dimensao),
shape = 21 ,
size = 3.5
) +
geom_point (
data = . %>%
filter (dimensao == "Transparência" ) %>%
mutate (indice = "Índice de Transparência" ),
size = .25
) +
geom_point (
data = . %>%
filter (dimensao == "Transparência" ) %>%
mutate (indice = "Índice de Transparência" ),
aes (color = indice),
size = 6 ,
alpha = .7
) +
scale_x_continuous (
limits = c (- .01 , max_limit),
breaks = c (0 , .25 , .5 , .75 , 1 ),
minor_breaks = c (.25 , .75 ),
expand = c (.001 , 0 ),
labels = ~ scales:: number (., decimal.mark = "," )
) +
scale_fill_manual (values = c (
"Completude" = cores_dadosjusbr[["laranja" ]],
"Facilidade" = cores_dadosjusbr[["lilas" ]]
)#, guide = "none"
) +
scale_color_manual (
values = cores_dadosjusbr[["cyan" ]]#, guide = "none"
) +
geom_curve (
data = cut_orgao,
aes (x = center, xend = pontuacao, y = aid, yend = aid),
color = cores_dadosjusbr[["cinza_azulado" ]],
size = .3 , arrow = arrow (length = unit (2 , "mm" )), curvature = - 0.15
) +
geom_label (
data = cut_orgao,
size = 3 ,
label.r = unit (.3 , "lines" ),
lineheight = 1.1 ,
aes (x = center, y = aid, label = lbl), fontface = "bold"
) +
labs (
title = NULL ,
x = "Pontuação" ,
y = NULL ,
fill = NULL ,
color = NULL
) +
theme (
plot.title = element_text (size = 13 ),
axis.title.x = element_text (vjust = - .5 , hjust = .8 ),
axis.ticks.x = element_blank (),
axis.text.x = element_text (vjust = - .2 ),
axis.text.y = element_text (hjust = 0 ),
legend.position = "top" ,
legend.justification = "left" ,
legend.background = element_rect (
fill = alpha (cores_dadosjusbr[["cinza_azulado" ]], .1 ),
color = "transparent"
)
)
}
```
::: {.panel-tabset}
#### Ranking Geral
```{r}
#| label: plot-indice-geral
#| echo: false
#| warning: false
#| message: false
#| fig-width: 10
#| fig-height: 25
plot_indice (df = indices_media_geral,
aid_cut = "MP-MS" ,
subgroup = indices %>% distinct (subgrupo) %>% pull (),
box_center = 1.3 ,
max_limit = 1.5 )
```
```{r}
#| label: save-plot-indice-geral
#| echo: false
#| warning: false
#| message: false
#| fig-width: 10
#| fig-height: 25
p <- plot_indice (df = indices_media_geral,
aid_cut = "MP-MS" ,
subgroup = indices %>% distinct (subgrupo) %>% pull (),
box_center = 1.3 ,
max_limit = 1.5 ) +
guides (fill = "none" , color = "none" )
ggsave (
here ("figure/indice-transparencia-ranking-geral.svg" ),
width = 2500 ,
height = 5000 ,
units = "px" ,
scale = 1
)
dev.off ()
```
#### MP
```{r}
#| label: plot-indice-mp
#| echo: false
#| warning: false
#| message: false
#| fig-width: 10
#| fig-height: 11
plot_indice (df = indices_media_geral,
aid_cut = "MP-PR" ,
subgroup = "Ministérios Públicos estaduais" ,
box_center = 1.3 ,
max_limit = 1.5 )
```
```{r}
#| label: save-plot-mp
#| echo: false
#| warning: false
#| message: false
p <- plot_indice (df = indices_media_geral,
aid_cut = "MP-MS" ,
subgroup = "Ministérios Públicos estaduais" ,
box_center = 1.3 ,
max_limit = 1.5 ) +
guides (fill = "none" , color = "none" )
ggsave (
here ("figure/indice-transparencia-mp.svg" ),
width = 3000 ,
height = 3000 ,
units = "px"
)
dev.off ()
```
#### TJ
```{r}
#| label: plot-indice-tj
#| echo: false
#| warning: false
#| message: false
#| fig-width: 10
#| fig-height: 11
plot_indice (df = indices_media_geral,
aid_cut = "TJ-MS" ,
subgroup = "Tribunais de Justiça estaduais" ,
box_center = 1.3 ,
max_limit = 1.5 )
```
```{r}
#| label: save-plot-tj
#| echo: false
#| warning: false
#| message: false
p <- plot_indice (df = indices_media_geral,
aid_cut = "TJ-MS" ,
subgroup = "Tribunais de Justiça estaduais" ,
box_center = 1.3 ,
max_limit = 1.5 ) +
guides (fill = "none" , color = "none" )
ggsave (
here ("figure/indice-transparencia-tj.svg" ),
width = 3000 ,
height = 3000 ,
units = "px"
)
dev.off ()
```
#### TRF
```{r}
#| label: plot-indice-trf
#| echo: false
#| warning: false
#| message: false
#| fig-width: 10
#| fig-height: 5
plot_indice (df = indices_media_geral,
aid_cut = "TRF-2" ,
subgroup = "Tribunais Regionais Federais" ,
box_center = 1.3 ,
max_limit = 1.5 )
```
```{r}
#| label: save-plot-trf
#| echo: false
#| warning: false
#| message: false
p <- plot_indice (df = indices_media_geral,
aid_cut = "TRF-2" ,
subgroup = "Tribunais Regionais Federais" ,
box_center = 1.3 ,
max_limit = 1.5 ) +
guides (fill = "none" , color = "none" )
ggsave (
here ("figure/indice-transparencia-trf.svg" ),
width = 3000 ,
height = 3000 ,
units = "px"
)
dev.off ()
```
#### TRT
```{r}
#| label: plot-indice-trt
#| echo: false
#| warning: false
#| message: false
#| fig-width: 10
#| fig-height: 9.5
plot_indice (df = indices_media_geral,
aid_cut = "TRT-5" ,
subgroup = "Tribunais Regionais do Trabalho" ,
box_center = 1.3 ,
max_limit = 1.5 )
```
```{r}
#| label: save-plot-trt
#| echo: false
#| warning: false
#| message: false
p <- plot_indice (df = indices_media_geral,
aid_cut = "TRT-5" ,
subgroup = "Tribunais Regionais do Trabalho" ,
box_center = 1.3 ,
max_limit = 1.5 ) +
guides (fill = "none" , color = "none" )
ggsave (
here ("figure/indice-transparencia-trt.svg" ),
width = 3000 ,
height = 3000 ,
units = "px"
)
dev.off ()
```
#### TJM
```{r}
#| label: plot-indice-tjm
#| echo: false
#| warning: false
#| message: false
#| fig-width: 10
#| fig-height: 3
plot_indice (df = indices_media_geral,
aid_cut = "TJM-RS" ,
subgroup = "Tribunais de Justiça Militar" ,
box_center = 1.3 ,
max_limit = 1.5 )
```
```{r}
#| label: save-plot-tjm
#| echo: false
#| warning: false
#| message: false
p <- plot_indice (df = indices_media_geral,
aid_cut = "TJM-RS" ,
subgroup = "Tribunais de Justiça Militar" ,
box_center = 1.3 ,
max_limit = 1.5 ) +
guides (fill = "none" , color = "none" )
ggsave (
here ("figure/indice-transparencia-tjm.svg" ),
width = 3000 ,
height = 3000 ,
units = "px"
)
dev.off ()
```
#### Órgãos superiores
```{r}
#| label: plot-indice-superiores
#| echo: false
#| warning: false
#| message: false
#| fig-width: 10
#| fig-height: 3
plot_indice (df = indices_media_geral,
aid_cut = "STJ" ,
subgroup = "Órgãos superiores" ,
box_center = 1.3 ,
max_limit = 1.5 )
```
```{r}
#| label: save-plot-superiores
#| echo: false
#| warning: false
#| message: false
p <- plot_indice (df = indices_media_geral,
aid_cut = "STJ" ,
subgroup = "Órgãos superiores" ,
box_center = 1.3 ,
max_limit = 1.5 ) +
guides (fill = "none" , color = "none" )
ggsave (
here ("figure/indice-transparencia-superiores.svg" ),
width = 3000 ,
height = 3000 ,
units = "px"
)
dev.off ()
```
:::