setwd("C:/IPP_Project_R_final")
library(tidyverse)
## -- Attaching packages ------------------------------------------------------------------ tidyverse 1.2.1 --
## v ggplot2 3.2.0 v purrr 0.3.2
## v tibble 2.1.3 v dplyr 0.8.0.1
## v tidyr 0.8.3 v stringr 1.4.0
## v readr 1.3.1 v forcats 0.4.0
## -- Conflicts --------------------------------------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(maptools)
## Loading required package: sp
## Checking rgeos availability: FALSE
## Note: when rgeos is not available, polygon geometry computations in maptools depend on gpclib,
## which has a restricted licence. It is disabled by default;
## to enable gpclib, type gpclibPermit()
library(descr)
library(gridExtra)
##
## Attaching package: 'gridExtra'
## The following object is masked from 'package:dplyr':
##
## combine
library(brmap)
## Loading required package: sf
## Linking to GEOS 3.6.1, GDAL 2.2.3, PROJ 4.9.3
library(viridis)
## Loading required package: viridisLite
library(scales)
##
## Attaching package: 'scales'
## The following object is masked from 'package:viridis':
##
## viridis_pal
## The following object is masked from 'package:purrr':
##
## discard
## The following object is masked from 'package:readr':
##
## col_factor
library(ggridges)
##
## Attaching package: 'ggridges'
## The following object is masked from 'package:ggplot2':
##
## scale_discrete_manual
##existencia de paridade
paridade <- function(x){
ifelse(x%in%c("Paritário","Sim", "É paritário", "Tem maior representação da sociedade civil"),1,ifelse(x%in%c("Não", "Não paritário", "Não aplicável","Não informado", "Não soube informar", "Não sabe informar", "Recusa", "Tem maior representação governamental", "Não está em funcionamento"), 0,NA))
}
# Função válida para deliberativos, consultivos, fiscalizadores e normativos
carater <- function(x){
ifelse(x=="Sim",1,ifelse(x%in%c("Não", "Não aplicável","Não informado", "Recusa", "Não soube informar", "Não sabe informar"), 0,NA))
}
theme_hist <- theme(axis.text.x = element_text(size = 12),
axis.text.y = element_text(size = 12),
axis.title.x = element_text(size = 12),
axis.title.y = element_text(size = 12))
theme_BOX <- theme(axis.text.x = element_text(size = 20),
axis.text.y = element_text(size = 20),
axis.title.x = element_text(size = 20),
axis.title.y = element_text(size = 20))
theme_map <- theme(panel.background = element_rect(fill = "transparent"),
panel.grid.major = element_line(color = "transparent"),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
axis.ticks = element_blank())
#### Carregar os dados do IBGE
Munics_IPs <- read_csv2("Munics_IPs.csv")
## Using ',' as decimal and '.' as grouping mark. Use read_delim() for more control.
## Parsed with column specification:
## cols(
## .default = col_character(),
## A1 = col_double(),
## A1a = col_double(),
## B2 = col_double(),
## B6 = col_double()
## )
## See spec(...) for full column specifications.
#### Carregar os dados da Legenda
Munics_IPs.legenda <- read.csv2("Legenda.csv", header=FALSE, stringsAsFactors=FALSE, encoding = "UTF-8")
## Selecionar unicamente o que corresponde a Munic 2013 e 2014
# filtrar linhas pela posição na base
# Legenda
Legenda_Munic_2014 <- slice(Munics_IPs.legenda,c(695:920, 1107:1152)) # O conselho de segurança alimentar aparecia duplicado # Agora excluído o código "A913".
# Base
Munic_2014 <- select(Munics_IPs, c(A1, A545:A740,A879:A912))
# O conselho de segurança alimentar aparecia duplicado # Agora excluído o código "A913".
# Bases suas
suas <- read_csv2("censo_suas.csv") %>%
select(IBGE, Porte_pop2010, Pop_Total2010)
## Using ',' as decimal and '.' as grouping mark. Use read_delim() for more control.
## Parsed with column specification:
## cols(
## IBGE = col_double(),
## IBGE7 = col_double(),
## UF = col_character(),
## `Munic<ed>pio` = col_character(),
## `Regi<e3>o` = col_character(),
## Porte_pop2010 = col_character(),
## Pop_Total2010 = col_double()
## )
suas <- descr::toUTF8(suas)
# IDH
idh <- read_csv2("idh_census.csv")
## Using ',' as decimal and '.' as grouping mark. Use read_delim() for more control.
## Parsed with column specification:
## cols(
## .default = col_double(),
## `Munic<ed>pio` = col_character(),
## T_FREQ0A3 = col_logical(),
## T_FREQ4A5 = col_logical(),
## T_FREQ4A6 = col_logical(),
## T_FREQFUND45 = col_logical(),
## CPR = col_logical(),
## EMP = col_logical(),
## P_AGRO = col_logical(),
## P_COM = col_logical(),
## P_CONSTR = col_logical(),
## P_EXTR = col_logical(),
## P_FORMAL = col_logical(),
## P_FUND = col_logical(),
## P_MED = col_logical(),
## P_SERV = col_logical(),
## P_SIUP = col_logical(),
## P_SUPER = col_logical(),
## P_TRANSF = col_logical(),
## REN0 = col_logical(),
## REN1 = col_logical()
## # ... with 34 more columns
## )
## See spec(...) for full column specifications.
## Warning: 584259 parsing failures.
## row col expected actual file
## 5566 T_FREQ0A3 1/0/T/F/TRUE/FALSE 0,65 'idh_census.csv'
## 5566 T_FREQ4A5 1/0/T/F/TRUE/FALSE 16,14 'idh_census.csv'
## 5566 T_FREQ4A6 1/0/T/F/TRUE/FALSE 27,51 'idh_census.csv'
## 5566 T_FREQFUND45 1/0/T/F/TRUE/FALSE 5,58 'idh_census.csv'
## 5566 CPR 1/0/T/F/TRUE/FALSE 47,37 'idh_census.csv'
## .... ............ .................. ...... ................
## See problems(...) for more details.
idh <- idh %>%
filter(ANO == "2010") %>%
select(Codmun6, IDHM) %>%
mutate(Codmun6 = as.numeric(Codmun6))
#####################################################################
######## 1. Quantidade de conselhos existentes nos municipios #######
#####################################################################
## Criar índice para selecionar unicamente a pergunta "O municipio possui Conselho Municipal...?"
##Coluna V3
index_cons <- str_which(Legenda_Munic_2014$V3,"possui Conselho Municipal")
### Usar o índice para selecionar as linhas.
Conselhos_lista <- slice(Legenda_Munic_2014,index_cons)
## Usar a coluna V17 que possui os códigos da base de dados
Conselhos_codigo <- Conselhos_lista$V17 #identificamos os códigos de cada conselho
##Selecionamos apenas as colunas correspondentes a "possui Conselho?"
Munic_2014_Conselhos <- select(Munic_2014,A1, Conselhos_codigo)
Munic_2014_Conselhos <- as.tibble(Munic_2014_Conselhos, row)
## Warning: `as.tibble()` is deprecated, use `as_tibble()` (but mind the new semantics).
## This warning is displayed once per session.
### Excluir conselhos da alimentacao escolar, transporte escolar e defesa civil
Munic_2014_Conselhos <- select(Munic_2014_Conselhos, -c(A607, A615, A724))
##Transformar os dados em indicadores.
# Efetuar soma para determinar o número de conselhos de cada municipio
Numero_conselhos <- Munic_2014_Conselhos %>%
mutate_at(vars(2:15), funs(ifelse(.=="Sim",1,0))) %>%
mutate(Num_conselhos = rowSums(select(., -A1)))
## Warning: funs() is soft deprecated as of dplyr 0.8.0
## please use list() instead
##
## # Before:
## funs(name = f(.)
##
## # After:
## list(name = ~f(.))
## This warning is displayed once per session.
# Verificar aplicação
apply(Numero_conselhos[2:15], 2, unique)
## A545 A553 A587 A623 A633 A641 A649 A657 A665 A673 A681 A715 A732 A891
## [1,] 1 0 0 1 0 1 0 1 0 0 0 1 1 1
## [2,] 0 1 1 0 1 0 1 0 1 1 1 0 0 0
summary(Numero_conselhos$Num_conselhos)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000 5.000 6.000 6.163 7.000 14.000
table(Numero_conselhos$Num_conselhos)
##
## 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
## 1 1 6 180 664 1377 1380 850 529 283 136 106 44 10 3
#seleção das variaveis auxiliares
Conselhos_Munic <- Munics_IPs %>%
select(A1:B6) %>%
left_join(suas, by = c("A1" = "IBGE"))
#Junção das bases
Conselhos_Munic <- Conselhos_Munic %>%
left_join(select(Numero_conselhos, A1, Num_conselhos))
## Joining, by = "A1"
#descr(Conselhos_Munic$Num_conselhos)
#descr::freq(Conselhos_Munic$Num_conselhos)
table_Num_Cons <- Numero_conselhos %>%
summarise_all(sum) %>%
gather() %>%
arrange(desc(value))
#table_Num_Cons
write_excel_csv2(table_Num_Cons, "Num. Conselhos.csv")
# Histrograma
hist_1 <- ggplot(Conselhos_Munic, aes(Num_conselhos)) +
geom_histogram(binwidth = 1, fill = "white", color = "black") +
ggtitle("Histogram 1", subtitle = "Number of councils per municipality")+
xlab("Number of councils") + ylab("Number of municipalities")+
scale_y_continuous(limits = c(0,1550), breaks = seq(0,1500, 250))+
#scale_x_continuous(limits = c(0, 18), breaks = seq(0, 20, 5))+
theme_classic() +
theme_hist
hist_1
#####################################################################
########### 2. Existencia de paridade nesse colegiados ##############
#####################################################################
## Criar índice para selecionar unicamente a pergunta "O conselho e paritario?"
index_pari <- str_which(Legenda_Munic_2014$V4,"paritário") ##Coluna V4
## usar a coluna V17 que possui os codigos da base de dados
Paridade_lista <- slice(Legenda_Munic_2014,index_pari)
#identificar os codigos de pergunta
Paridade_codigo <- Paridade_lista$V17
## Sel. apenas as colunas correspondentes a "O Conselho e paritario?"
Munic_2014_Paridade <- select(Munic_2014, A1, Paridade_codigo)
# Verificar rótulos
sapply(Munic_2014_Paridade[2:18], FUN = unique) # Há um erro de digitação Naão sabe
## $A547
## [1] "Naão sabe informar" "Sim" "Não aplicável"
## [4] "Não" "Recusa" "Não sabe informar"
##
## $A555
## [1] "Não aplicável" "Sim" "Não"
## [4] "Recusa" "Não sabe informar"
##
## $A589
## [1] "Não aplicável" "Paritário" "Não paritário" "Não informado"
## [5] "Recusa"
##
## $A609
## [1] "Paritário" "Não aplicável" "Não paritário" "Não informado"
## [5] "Recusa"
##
## $A617
## [1] "Não aplicável" "Paritário" "Não paritário" "Não informado"
## [5] "Recusa"
##
## $A625
## [1] "Paritário" "Não aplicável" "Não paritário" "Recusa"
## [5] "Não informado"
##
## $A635
## [1] "Não aplicável" "Paritário" "Não paritário" "Recusa"
## [5] "Não informado"
##
## $A643
## [1] "Paritário" "Não aplicável" "Não paritário" "Recusa"
## [5] "Não informado"
##
## $A651
## [1] "Não aplicável" "Paritário" "Não paritário" "Recusa"
## [5] "Não informado"
##
## $A659
## [1] "Paritário" "Não aplicável" "Não paritário" "Não informado"
## [5] "Recusa"
##
## $A667
## [1] "Não aplicável" "Paritário" "Não paritário" "Recusa"
## [5] "Não informado"
##
## $A675
## [1] "Não aplicável" "Recusa" "Paritário" "Não paritário"
## [5] "Não informado"
##
## $A683
## [1] "Não aplicável" "Paritário" "Não paritário" "Recusa"
## [5] "Não informado"
##
## $A717
## [1] "Não paritário" "Paritário"
## [3] "Não aplicável" "Recusa"
## [5] "Não está em funcionamento" "Não informado"
##
## $A726
## [1] "Não aplicável" "Paritário" "Não paritário"
## [4] "Recusa" "Não soube informar" "Não informado"
##
## $A734
## [1] "Paritário" "Não aplicável" "Não paritário" "Recusa"
## [5] "Não informado"
##
## $A893
## [1] "É paritário"
## [2] "Tem maior representação da sociedade civil"
## [3] "Tem maior representação governamental"
## [4] "Não aplicável"
## [5] "Recusa"
Munic_2014_Paridade$A547[1] <- "Não sabe informar"
### Excluir conselhos da alimentacao escolar, transporte escolar e defesa civil
Munic_2014_Paridade <- select(Munic_2014_Paridade, -c(A609, A617, A726))
##Transformar dados em indicadores.
# Efetuamos a soma para determinar o numero de conselhos paritarios de cada municipio
Paridade_pond <- Munic_2014_Paridade %>%
mutate_at(vars(2:15), funs(paridade(.))) %>%
mutate(Paridade = rowSums(select(., -A1)))
apply(Paridade_pond[2:16], 2, FUN = unique)
## $A547
## [1] 0 1
##
## $A555
## [1] 0 1
##
## $A589
## [1] 0 1
##
## $A625
## [1] 1 0
##
## $A635
## [1] 0 1
##
## $A643
## [1] 1 0
##
## $A651
## [1] 0 1
##
## $A659
## [1] 1 0
##
## $A667
## [1] 0 1
##
## $A675
## [1] 0 1
##
## $A683
## [1] 0 1
##
## $A717
## [1] 0 1
##
## $A734
## [1] 1 0
##
## $A893
## [1] 1 0
##
## $Paridade
## [1] 5 11 9 6 3 7 8 4 2 10 0 12 14 1 13
### Juntar estes valores de paridade com a suas repectivos municipios
# Utilizar a tabela anterior 'Conselhos _Munic' que ja contem o numero de conselhos (deve primerio correr o indicador 1)
Paridade_Munic <- Conselhos_Munic%>%
left_join(select(Paridade_pond, A1, Paridade))
## Joining, by = "A1"
glimpse(Paridade_Munic)
## Observations: 5,570
## Variables: 12
## $ A1 <dbl> 110001, 110002, 110003, 110004, 110005, 110006, ...
## $ A1a <dbl> 1100015, 1100023, 1100031, 1100049, 1100056, 110...
## $ B1 <chr> "ALTA FLORESTA DOESTE", "ARIQUEMES", "CABIXI", "...
## $ B2 <dbl> 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, ...
## $ B3 <chr> "RO", "RO", "RO", "RO", "RO", "RO", "RO", "RO", ...
## $ B4 <chr> "1 - Norte", "1 - Norte", "1 - Norte", "1 - Nort...
## $ B5 <chr> "4 - 20001 até 50000", "6 - 100001 até 500000", ...
## $ B6 <dbl> 25578, 104401, 6355, 87226, 17986, 18817, 8842, ...
## $ Porte_pop2010 <chr> "Pequeno II", "Médio", "Pequeno I", "Médio", "Pe...
## $ Pop_Total2010 <dbl> 24392, 90353, 6313, 78574, 17029, 18591, 8783, 1...
## $ Num_conselhos <dbl> 7, 11, 5, 10, 6, 3, 3, 5, 6, 8, 6, 8, 4, 6, 6, 5...
## $ Paridade <dbl> 5, 11, 5, 9, 6, 3, 3, 5, 5, 7, 6, 8, 4, 6, 5, 3,...
descr(Paridade_Munic$Paridade)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000 5.000 6.000 5.834 7.000 14.000
freq(Paridade_Munic$Paridade)
## Paridade_Munic$Paridade
## Frequency Percent
## 0 1 0.01795
## 1 2 0.03591
## 2 30 0.53860
## 3 276 4.95512
## 4 833 14.95512
## 5 1479 26.55296
## 6 1316 23.62657
## 7 774 13.89587
## 8 462 8.29443
## 9 214 3.84201
## 10 106 1.90305
## 11 50 0.89767
## 12 23 0.41293
## 13 2 0.03591
## 14 2 0.03591
## Total 5570 100.00000
table_Num_pari <- Paridade_pond %>%
summarise_all(sum)%>%
gather() %>%
arrange(desc(value))
table_Num_pari
## # A tibble: 16 x 2
## key value
## <chr> <dbl>
## 1 A1 1812247557
## 2 Paridade 32493
## 3 A893 5515
## 4 A625 5429
## 5 A643 5378
## 6 A589 4496
## 7 A547 3503
## 8 A659 3365
## 9 A734 1199
## 10 A667 1042
## 11 A555 890
## 12 A717 561
## 13 A683 534
## 14 A635 304
## 15 A651 257
## 16 A675 20
write_excel_csv2(table_Num_pari, "Num. paritário.csv")
# Histograma
hist_2 <- ggplot(Paridade_Munic, aes(Paridade)) +
geom_histogram(binwidth = 1, fill = "white", color = "black") +
ggtitle("Histogram 2", subtitle = "Number of joint councils, quantity per municipality")+
xlab("Number of joint councils") + ylab("") +
scale_y_continuous(limits = c(0,1550), breaks = seq(0,1500, 250))+
#scale_x_continuous(limits = c(0,18), breaks = seq(0, 20, 5))+
theme_classic()+
theme_hist
hist_2
###################################################################
############# 3. O Caráter debilerativo desses órgãos ############
#################################################################
##3.1. Criar indice para selecionar unicamente a pergunta "Deliberativo"
##Coluna V5 inclui o caráter do conselho
index_deli <- str_which(Legenda_Munic_2014$V5,"Deliberativo")
## Usar a coluna V17 que possui os códigos da base de dados
Delib_lista <- slice(Legenda_Munic_2014,index_deli)
#identificar códigos de pergunta
Delib_codigo <- Delib_lista$V17
##Selecionamos apenas as colunas correspondentes a "Deliberativo"
Munic_2014_Delib <- select(Munic_2014, A1, Delib_codigo)
### Excluir conselhos da alimentacao escolar, transporte escolar e defesa civil
Munic_2014_Delib <- select(Munic_2014_Delib, -c(A611, A619, A728))
sapply(Munic_2014_Delib[2:15], 2, FUN = unique)
## $A549
## [1] "Sim" "Não aplicável" "Não"
## [4] "Recusa" "Não sabe informar"
##
## $A557
## [1] "Não aplicável" "Sim" "Não" "Recusa"
##
## $A591
## [1] "Não aplicável" "Sim" "Não" "Não informado"
## [5] "Recusa"
##
## $A627
## [1] "Sim" "Não" "Não aplicável" "Recusa"
## [5] "Não informado"
##
## $A637
## [1] "Não aplicável" "Sim" "Não" "Recusa"
## [5] "Não informado"
##
## $A645
## [1] "Sim" "Não" "Não aplicável" "Recusa"
## [5] "Não informado"
##
## $A653
## [1] "Não aplicável" "Sim" "Não" "Recusa"
## [5] "Não informado"
##
## $A661
## [1] "Sim" "Não aplicável" "Não" "Não informado"
## [5] "Recusa"
##
## $A669
## [1] "Não aplicável" "Sim" "Não" "Recusa"
## [5] "Não informado"
##
## $A677
## [1] "Não aplicável" "Recusa" "Sim" "Não"
## [5] "Não informado"
##
## $A685
## [1] "Não aplicável" "Sim" "Não" "Recusa"
## [5] "Não informado"
##
## $A719
## [1] "Não" "Sim" "Não aplicável" "Recusa"
## [5] "Não informado"
##
## $A736
## [1] "Não" "Sim" "Não aplicável" "Recusa"
## [5] "Não informado"
##
## $A897
## [1] "Sim" "Não" "Não aplicável" "Recusa"
##Transfor os dados em indicadores
#efetuar a soma para determinar o número de conselhos deliberativos
Delib_pond <- Munic_2014_Delib %>%
mutate_at(vars(2:15), funs(carater(.)))%>%
mutate(Deliberativos = rowSums(select(., -A1)))
apply(Delib_pond[2:16], 2, unique)
## $A549
## [1] 1 0
##
## $A557
## [1] 0 1
##
## $A591
## [1] 0 1
##
## $A627
## [1] 1 0
##
## $A637
## [1] 0 1
##
## $A645
## [1] 1 0
##
## $A653
## [1] 0 1
##
## $A661
## [1] 1 0
##
## $A669
## [1] 0 1
##
## $A677
## [1] 0 1
##
## $A685
## [1] 0 1
##
## $A719
## [1] 0 1
##
## $A736
## [1] 0 1
##
## $A897
## [1] 1 0
##
## $Deliberativos
## [1] 5 11 9 2 3 6 4 8 10 7 1 0 12 13
##Adicionamos os valores da tabela "Paridade_Munic"
Delib_Munic <- Paridade_Munic %>%
left_join(select(Delib_pond, A1, Deliberativos))
## Joining, by = "A1"
glimpse(Delib_Munic)
## Observations: 5,570
## Variables: 13
## $ A1 <dbl> 110001, 110002, 110003, 110004, 110005, 110006, ...
## $ A1a <dbl> 1100015, 1100023, 1100031, 1100049, 1100056, 110...
## $ B1 <chr> "ALTA FLORESTA DOESTE", "ARIQUEMES", "CABIXI", "...
## $ B2 <dbl> 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, ...
## $ B3 <chr> "RO", "RO", "RO", "RO", "RO", "RO", "RO", "RO", ...
## $ B4 <chr> "1 - Norte", "1 - Norte", "1 - Norte", "1 - Nort...
## $ B5 <chr> "4 - 20001 até 50000", "6 - 100001 até 500000", ...
## $ B6 <dbl> 25578, 104401, 6355, 87226, 17986, 18817, 8842, ...
## $ Porte_pop2010 <chr> "Pequeno II", "Médio", "Pequeno I", "Médio", "Pe...
## $ Pop_Total2010 <dbl> 24392, 90353, 6313, 78574, 17029, 18591, 8783, 1...
## $ Num_conselhos <dbl> 7, 11, 5, 10, 6, 3, 3, 5, 6, 8, 6, 8, 4, 6, 6, 5...
## $ Paridade <dbl> 5, 11, 5, 9, 6, 3, 3, 5, 5, 7, 6, 8, 4, 6, 5, 3,...
## $ Deliberativos <dbl> 5, 11, 5, 9, 5, 2, 3, 5, 6, 4, 4, 8, 3, 5, 5, 5,...
# Plots
descr::freq(as.factor(Delib_pond$Deliberativos))
## as.factor(Delib_pond$Deliberativos)
## Frequency Percent
## 0 5 0.08977
## 1 47 0.84381
## 2 160 2.87253
## 3 556 9.98205
## 4 1069 19.19210
## 5 1428 25.63734
## 6 1087 19.51526
## 7 601 10.78995
## 8 348 6.24776
## 9 162 2.90844
## 10 67 1.20287
## 11 32 0.57451
## 12 7 0.12567
## 13 1 0.01795
## Total 5570 100.00000
descr(Delib_pond$Deliberativos)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000 4.000 5.000 5.304 6.000 13.000
table_Num_del <- Delib_pond %>%
summarise_all(sum)%>%
gather() %>%
arrange(desc(value))
table_Num_del
## # A tibble: 16 x 2
## key value
## <chr> <dbl>
## 1 A1 1812247557
## 2 Deliberativos 29541
## 3 A897 5335
## 4 A627 5006
## 5 A645 4916
## 6 A591 4101
## 7 A549 3238
## 8 A661 2939
## 9 A736 994
## 10 A669 907
## 11 A557 731
## 12 A719 436
## 13 A685 434
## 14 A637 278
## 15 A653 211
## 16 A677 15
write_excel_csv2(table_Num_del, "Num. deliberativos.csv")
### Histogram deliberativos
hist_3 <- ggplot(Delib_pond, aes(Deliberativos)) +
geom_histogram(binwidth = 1, fill= "white", color="black") +
ggtitle("Histogram 3", subtitle = "Number of deliberative councils, quantity per municipality")+
xlab("Number of deliberative councils") + ylab("") +
scale_y_continuous(limits = c(0,1550), breaks = seq(0,1500, 250))+
scale_x_continuous(limits = c(0,18), breaks = seq(0, 20, 5))+
theme_classic()+
theme_hist
hist_3
## Warning: Removed 2 rows containing missing values (geom_bar).
#######################################################################
##3.2. indice para selecionar unicamente a opção "Consultivo"###
#######################################################################
# Mesmo procedimento anterior
index_consul <- str_which(Legenda_Munic_2014$V5,"Consultivo")
Consul_lista <- slice(Legenda_Munic_2014,index_consul)
Consul_codigo <- Consul_lista$V17
Munic_2014_Consul <- select(Munic_2014, A1, Consul_codigo)
### Excluir conselhos da alimentacao escolar, transporte escolar e defesa civil
Munic_2014_Consul <- select(Munic_2014_Consul, -c(A610, A618, A727))
apply(Munic_2014_Consul[2:15], 2, FUN = unique)
## $A548
## [1] "Sim" "Não" "Não aplicável"
## [4] "Recusa" "Não sabe informar"
##
## $A556
## [1] "Não aplicável" "Sim" "Não" "Recusa"
##
## $A590
## [1] "Não aplicável" "Sim" "Não" "Não informado"
## [5] "Recusa"
##
## $A626
## [1] "Não" "Sim" "Não aplicável" "Recusa"
## [5] "Não informado"
##
## $A636
## [1] "Não aplicável" "Sim" "Não" "Recusa"
## [5] "Não informado"
##
## $A644
## [1] "Sim" "Não" "Não aplicável" "Recusa"
## [5] "Não informado"
##
## $A652
## [1] "Não aplicável" "Sim" "Não" "Recusa"
## [5] "Não informado"
##
## $A660
## [1] "Sim" "Não" "Não aplicável" "Não informado"
## [5] "Recusa"
##
## $A668
## [1] "Não aplicável" "Sim" "Não" "Recusa"
## [5] "Não informado"
##
## $A676
## [1] "Não aplicável" "Recusa" "Sim" "Não"
## [5] "Não informado"
##
## $A684
## [1] "Não aplicável" "Sim" "Não" "Recusa"
## [5] "Não informado"
##
## $A718
## [1] "Sim" "Não aplicável" "Não" "Recusa"
## [5] "Não informado"
##
## $A735
## [1] "Sim" "Não aplicável" "Não" "Recusa"
## [5] "Não informado"
##
## $A896
## [1] "Sim" "Não" "Não aplicável" "Recusa"
## Transformar dados em indicadores
# efetuamos a soma para determinar o número de conselhos consultivos
Consul_pond <- Munic_2014_Consul%>%
mutate_at(vars(2:15),funs(carater(.)))%>%
mutate(Consultivos = rowSums(select(., -A1)))
apply(Consul_pond[2:16], 2, unique)
## $A548
## [1] 1 0
##
## $A556
## [1] 0 1
##
## $A590
## [1] 0 1
##
## $A626
## [1] 0 1
##
## $A636
## [1] 0 1
##
## $A644
## [1] 1 0
##
## $A652
## [1] 0 1
##
## $A660
## [1] 1 0
##
## $A668
## [1] 0 1
##
## $A676
## [1] 0 1
##
## $A684
## [1] 0 1
##
## $A718
## [1] 1 0
##
## $A735
## [1] 1 0
##
## $A896
## [1] 1 0
##
## $Consultivos
## [1] 6 10 0 4 5 2 1 3 7 8 11 9 14 12 13
sum(Consul_pond$Consultivos)
## [1] 23849
##
descr(Consul_pond$Consultivos)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000 3.000 4.000 4.282 6.000 14.000
descr::freq(as.factor(Consul_pond$Consultivos))
## as.factor(Consul_pond$Consultivos)
## Frequency Percent
## 0 80 1.43627
## 1 341 6.12208
## 2 661 11.86715
## 3 1039 18.65350
## 4 1109 19.91023
## 5 893 16.03232
## 6 666 11.95691
## 7 379 6.80431
## 8 218 3.91382
## 9 106 1.90305
## 10 51 0.91562
## 11 18 0.32316
## 12 6 0.10772
## 13 1 0.01795
## 14 2 0.03591
## Total 5570 100.00000
glimpse(Consul_pond)
## Observations: 5,570
## Variables: 16
## $ A1 <dbl> 110001, 110002, 110003, 110004, 110005, 110006, 11...
## $ A548 <dbl> 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0,...
## $ A556 <dbl> 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1,...
## $ A590 <dbl> 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1,...
## $ A626 <dbl> 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0,...
## $ A636 <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,...
## $ A644 <dbl> 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 1,...
## $ A652 <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,...
## $ A660 <dbl> 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1,...
## $ A668 <dbl> 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 1,...
## $ A676 <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...
## $ A684 <dbl> 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...
## $ A718 <dbl> 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,...
## $ A735 <dbl> 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1,...
## $ A896 <dbl> 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0,...
## $ Consultivos <dbl> 6, 10, 0, 4, 5, 2, 1, 5, 3, 7, 3, 4, 4, 4, 5, 3, 7...
##Adicionamos os valores na tabela "Delib_Munic"
Consul_Munic <- Delib_Munic %>%
left_join(select(Consul_pond, A1, Consultivos))
## Joining, by = "A1"
glimpse(Consul_Munic)
## Observations: 5,570
## Variables: 14
## $ A1 <dbl> 110001, 110002, 110003, 110004, 110005, 110006, ...
## $ A1a <dbl> 1100015, 1100023, 1100031, 1100049, 1100056, 110...
## $ B1 <chr> "ALTA FLORESTA DOESTE", "ARIQUEMES", "CABIXI", "...
## $ B2 <dbl> 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, ...
## $ B3 <chr> "RO", "RO", "RO", "RO", "RO", "RO", "RO", "RO", ...
## $ B4 <chr> "1 - Norte", "1 - Norte", "1 - Norte", "1 - Nort...
## $ B5 <chr> "4 - 20001 até 50000", "6 - 100001 até 500000", ...
## $ B6 <dbl> 25578, 104401, 6355, 87226, 17986, 18817, 8842, ...
## $ Porte_pop2010 <chr> "Pequeno II", "Médio", "Pequeno I", "Médio", "Pe...
## $ Pop_Total2010 <dbl> 24392, 90353, 6313, 78574, 17029, 18591, 8783, 1...
## $ Num_conselhos <dbl> 7, 11, 5, 10, 6, 3, 3, 5, 6, 8, 6, 8, 4, 6, 6, 5...
## $ Paridade <dbl> 5, 11, 5, 9, 6, 3, 3, 5, 5, 7, 6, 8, 4, 6, 5, 3,...
## $ Deliberativos <dbl> 5, 11, 5, 9, 5, 2, 3, 5, 6, 4, 4, 8, 3, 5, 5, 5,...
## $ Consultivos <dbl> 6, 10, 0, 4, 5, 2, 1, 5, 3, 7, 3, 4, 4, 4, 5, 3,...
## table
table_Num_Cons <- Consul_pond %>%
summarise_all(sum)%>%
gather() %>%
arrange(desc(value))
table_Num_Cons
## # A tibble: 16 x 2
## key value
## <chr> <dbl>
## 1 A1 1812247557
## 2 Consultivos 23849
## 3 A590 4166
## 4 A644 3394
## 5 A626 3302
## 6 A896 3261
## 7 A548 3064
## 8 A660 2431
## 9 A735 1308
## 10 A668 772
## 11 A556 710
## 12 A684 497
## 13 A718 495
## 14 A636 222
## 15 A652 212
## 16 A676 15
write_excel_csv2(table_Num_Cons, "table_Num_Cons.csv")
### Histogram Consultivos
hist_4 <- ggplot(Consul_pond, aes(Consultivos)) +
geom_histogram(binwidth = 1, fill= "white", color="black") +
ggtitle("Histogram 4", subtitle = "Number of consultative councils, quantity per municipality")+
xlab("Number of consultative councils") + ylab("Number of municipalities")+
scale_y_continuous(limits = c(0,1550), breaks = seq(0,1500, 250))+
#scale_x_continuous(limits = c(0,18), breaks = seq(0, 20, 5)) +
theme_classic()+
theme_hist
hist_4
##3.3. indice para selecionar unicamente a opção "Normativo"
# Mesmo procedimento
index_norma <- str_which(Legenda_Munic_2014$V5,"Normativo")
Norma_lista <- slice(Legenda_Munic_2014,index_norma)
Norma_codigo <- Norma_lista$V17
Munic_2014_Norma <- select(Munic_2014,A1, Norma_codigo)
### Excluir conselhos da alimentacao escolar, transporte escolar e defesa civil
Munic_2014_Norma <- select(Munic_2014_Norma, -c(A612, A620, A729))
##Transformamos os dados em indicadores
Norma_pond <- Munic_2014_Norma %>%
mutate_at(vars(2:15), funs(carater(.)))%>%
mutate(Normativos = rowSums(select(., - A1)))
apply(Norma_pond[2:16], 2, unique)
## $A550
## [1] 0 1
##
## $A558
## [1] 0 1
##
## $A592
## [1] 0 1
##
## $A628
## [1] 0 1
##
## $A638
## [1] 0 1
##
## $A646
## [1] 0 1
##
## $A654
## [1] 0 1
##
## $A662
## [1] 0 1
##
## $A670
## [1] 0 1
##
## $A678
## [1] 0 1
##
## $A686
## [1] 0 1
##
## $A720
## [1] 0 1
##
## $A737
## [1] 0 1
##
## $A898
## [1] 1 0
##
## $Normativos
## [1] 1 8 0 3 6 2 5 7 4 10 9 11 12
descr(Norma_pond$Normativos)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.000 2.000 3.000 3.058 4.000 12.000
descr::freq(as.factor(Norma_pond$Normativos))
## as.factor(Norma_pond$Normativos)
## Frequency Percent
## 0 320 5.74506
## 1 845 15.17056
## 2 1199 21.52603
## 3 1159 20.80790
## 4 887 15.92460
## 5 607 10.89767
## 6 304 5.45781
## 7 135 2.42370
## 8 80 1.43627
## 9 21 0.37702
## 10 10 0.17953
## 11 2 0.03591
## 12 1 0.01795
## Total 5570 100.00000
##Adicionamos os valores na tabela "Delib_Munic"
Norma_Munic <- Consul_Munic %>%
left_join(select(Norma_pond, A1, Normativos))
## Joining, by = "A1"
glimpse(Norma_Munic)
## Observations: 5,570
## Variables: 15
## $ A1 <dbl> 110001, 110002, 110003, 110004, 110005, 110006, ...
## $ A1a <dbl> 1100015, 1100023, 1100031, 1100049, 1100056, 110...
## $ B1 <chr> "ALTA FLORESTA DOESTE", "ARIQUEMES", "CABIXI", "...
## $ B2 <dbl> 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, ...
## $ B3 <chr> "RO", "RO", "RO", "RO", "RO", "RO", "RO", "RO", ...
## $ B4 <chr> "1 - Norte", "1 - Norte", "1 - Norte", "1 - Nort...
## $ B5 <chr> "4 - 20001 até 50000", "6 - 100001 até 500000", ...
## $ B6 <dbl> 25578, 104401, 6355, 87226, 17986, 18817, 8842, ...
## $ Porte_pop2010 <chr> "Pequeno II", "Médio", "Pequeno I", "Médio", "Pe...
## $ Pop_Total2010 <dbl> 24392, 90353, 6313, 78574, 17029, 18591, 8783, 1...
## $ Num_conselhos <dbl> 7, 11, 5, 10, 6, 3, 3, 5, 6, 8, 6, 8, 4, 6, 6, 5...
## $ Paridade <dbl> 5, 11, 5, 9, 6, 3, 3, 5, 5, 7, 6, 8, 4, 6, 5, 3,...
## $ Deliberativos <dbl> 5, 11, 5, 9, 5, 2, 3, 5, 6, 4, 4, 8, 3, 5, 5, 5,...
## $ Consultivos <dbl> 6, 10, 0, 4, 5, 2, 1, 5, 3, 7, 3, 4, 4, 4, 5, 3,...
## $ Normativos <dbl> 1, 8, 0, 3, 6, 2, 1, 5, 1, 5, 1, 6, 1, 5, 5, 3, ...
# Table
table_Num_Norma <- Norma_pond %>%
summarise_all(sum)%>%
gather() %>%
arrange(desc(value))
table_Num_Norma
## # A tibble: 16 x 2
## key value
## <chr> <dbl>
## 1 A1 1812247557
## 2 Normativos 17035
## 3 A592 3270
## 4 A898 3055
## 5 A646 2805
## 6 A628 2586
## 7 A550 1612
## 8 A662 1598
## 9 A737 522
## 10 A670 471
## 11 A558 406
## 12 A686 229
## 13 A720 195
## 14 A638 162
## 15 A654 115
## 16 A678 9
write_excel_csv2(table_Num_Norma, "table_Num_Norma.csv")
### Histogram normativos
hist_5 <- ggplot(Norma_pond, aes(Normativos)) +
geom_histogram(binwidth = 1, fill= "white", color="black") +
ggtitle("Histogram 5", subtitle = "Number of normative councils, quantity per municipality")+
xlab("Number of normative councils") + ylab("")+
scale_y_continuous(limits = c(0,1550), breaks = seq(0,1500, 250))+
scale_x_continuous(limits = c(0,18), breaks = seq(0, 20, 5)) +
theme_classic()+
theme_hist
hist_5
## Warning: Removed 2 rows containing missing values (geom_bar).
##3.4. indice para selecionar unicamente a opção "Fiscalizador"
# Mesmo procedimento
index_fisca <- str_which(Legenda_Munic_2014$V5,"Fiscalizador")
Fisca_lista <- slice(Legenda_Munic_2014,index_fisca)
Fisca_codigo <- Fisca_lista$V17
Munic_2014_Fisca <- select(Munic_2014, A1, Fisca_codigo)
### Excluir conselhos da alimentacao escolar, transporte escolar e defesa civil
Munic_2014_Fisca <- select(Munic_2014_Fisca, -c(A613, A621, A730))
##Transformamos os dados em indicadores
# Efetuar a soma para determinar o número de conselhos fiscalizadores
Fisca_pond <- Munic_2014_Fisca %>%
mutate_at(vars(2:15),funs(carater(.)))%>%
mutate(Fiscalizadores = rowSums(select(., - A1)))
apply(Fisca_pond[2:16], 2, unique)
## $A551
## [1] 1 0
##
## $A559
## [1] 0 1
##
## $A593
## [1] 0 1
##
## $A629
## [1] 0 1
##
## $A639
## [1] 0 1
##
## $A647
## [1] 0 1
##
## $A655
## [1] 0 1
##
## $A663
## [1] 0 1
##
## $A671
## [1] 0 1
##
## $A679
## [1] 0 1
##
## $A687
## [1] 0 1
##
## $A721
## [1] 0 1
##
## $A738
## [1] 0 1
##
## $A899
## [1] 1 0
##
## $Fiscalizadores
## [1] 2 9 4 3 5 6 8 1 7 10 0 12 11
glimpse(Fisca_pond)
## Observations: 5,570
## Variables: 16
## $ A1 <dbl> 110001, 110002, 110003, 110004, 110005, 110006,...
## $ A551 <dbl> 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0,...
## $ A559 <dbl> 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0,...
## $ A593 <dbl> 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1,...
## $ A629 <dbl> 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1,...
## $ A639 <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,...
## $ A647 <dbl> 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0,...
## $ A655 <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...
## $ A663 <dbl> 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0,...
## $ A671 <dbl> 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...
## $ A679 <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...
## $ A687 <dbl> 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,...
## $ A721 <dbl> 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,...
## $ A738 <dbl> 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,...
## $ A899 <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,...
## $ Fiscalizadores <dbl> 2, 9, 4, 3, 4, 3, 2, 5, 3, 6, 4, 4, 2, 6, 5, 4,...
##
descr::freq(as.factor(Fisca_pond$Fiscalizadores))
## as.factor(Fisca_pond$Fiscalizadores)
## Frequency Percent
## 0 25 0.44883
## 1 196 3.51885
## 2 519 9.31777
## 3 984 17.66607
## 4 1317 23.64452
## 5 1206 21.65171
## 6 683 12.26212
## 7 352 6.31957
## 8 186 3.33932
## 9 63 1.13106
## 10 26 0.46679
## 11 9 0.16158
## 12 4 0.07181
## Total 5570 100.00000
##Adicionar os valores à tabela "Delib_Munic"
Fisca_Munic <- Norma_Munic %>%
left_join(select(Fisca_pond,A1, Fiscalizadores))
## Joining, by = "A1"
glimpse(Fisca_Munic)
## Observations: 5,570
## Variables: 16
## $ A1 <dbl> 110001, 110002, 110003, 110004, 110005, 110006,...
## $ A1a <dbl> 1100015, 1100023, 1100031, 1100049, 1100056, 11...
## $ B1 <chr> "ALTA FLORESTA DOESTE", "ARIQUEMES", "CABIXI", ...
## $ B2 <dbl> 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,...
## $ B3 <chr> "RO", "RO", "RO", "RO", "RO", "RO", "RO", "RO",...
## $ B4 <chr> "1 - Norte", "1 - Norte", "1 - Norte", "1 - Nor...
## $ B5 <chr> "4 - 20001 até 50000", "6 - 100001 até 500000",...
## $ B6 <dbl> 25578, 104401, 6355, 87226, 17986, 18817, 8842,...
## $ Porte_pop2010 <chr> "Pequeno II", "Médio", "Pequeno I", "Médio", "P...
## $ Pop_Total2010 <dbl> 24392, 90353, 6313, 78574, 17029, 18591, 8783, ...
## $ Num_conselhos <dbl> 7, 11, 5, 10, 6, 3, 3, 5, 6, 8, 6, 8, 4, 6, 6, ...
## $ Paridade <dbl> 5, 11, 5, 9, 6, 3, 3, 5, 5, 7, 6, 8, 4, 6, 5, 3...
## $ Deliberativos <dbl> 5, 11, 5, 9, 5, 2, 3, 5, 6, 4, 4, 8, 3, 5, 5, 5...
## $ Consultivos <dbl> 6, 10, 0, 4, 5, 2, 1, 5, 3, 7, 3, 4, 4, 4, 5, 3...
## $ Normativos <dbl> 1, 8, 0, 3, 6, 2, 1, 5, 1, 5, 1, 6, 1, 5, 5, 3,...
## $ Fiscalizadores <dbl> 2, 9, 4, 3, 4, 3, 2, 5, 3, 6, 4, 4, 2, 6, 5, 4,...
descr(Fisca_Munic$Fiscalizadores)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0 3.0 4.0 4.4 5.0 12.0
freq(Fisca_Munic$Fiscalizadores)
## Fisca_Munic$Fiscalizadores
## Frequency Percent
## 0 25 0.44883
## 1 196 3.51885
## 2 519 9.31777
## 3 984 17.66607
## 4 1317 23.64452
## 5 1206 21.65171
## 6 683 12.26212
## 7 352 6.31957
## 8 186 3.33932
## 9 63 1.13106
## 10 26 0.46679
## 11 9 0.16158
## 12 4 0.07181
## Total 5570 100.00000
### table
# Table
table_Num_Fisc <- Fisca_pond %>%
summarise_all(sum)%>%
gather() %>%
arrange(desc(value))
table_Num_Fisc
## # A tibble: 16 x 2
## key value
## <chr> <dbl>
## 1 A1 1812247557
## 2 Fiscalizadores 24508
## 3 A899 4742
## 4 A629 4325
## 5 A647 4099
## 6 A593 3816
## 7 A663 2366
## 8 A551 1829
## 9 A738 853
## 10 A671 725
## 11 A559 619
## 12 A687 371
## 13 A721 358
## 14 A639 230
## 15 A655 161
## 16 A679 14
write_excel_csv2(table_Num_Fisc, "table_Num_Fisc.csv")
### Histogram
hist_6 <- ggplot(Fisca_Munic, aes(Fiscalizadores)) +
geom_histogram(binwidth = 1, fill = "white", color="black") +
scale_y_continuous(limits = c(0,1550), breaks = seq(0,1500, 250))+
scale_x_continuous(limits = c(0,18), breaks = seq(0, 20, 5)) +
ggtitle("Histogram 6", subtitle = "Number of watchdog councils, quantity per municipality")+
xlab("Number of watchdog councils") + ylab("")+
theme_classic()+
theme_hist
hist_6
## Warning: Removed 2 rows containing missing values (geom_bar).
#####################################################################
######### 4. Quantidade de reuniões nos últimos 12 meses ##########
#####################################################################
## indice para selecionar unicamente a pergunta "número de rueniões?"
index_reu <- str_which(Legenda_Munic_2014$V4,"reuni") ##Coluna V4
Reuni_lista <- Legenda_Munic_2014 %>%
slice(index_reu) %>%
slice(-4)## tirar fila 4. Conselho do Fundeb; porque é um "conselho de controle...", mas que não tem as outras caracteristicas para avalair, Ou seja, não pode ser avalaido da mesma forma que os outros conselhos, portanto tiro fora da lista
Reuni_codigo <- Reuni_lista$V17 #extraimos os códigos de cada pergunta
##Selecionamos apenas as colunas correspondentes a "número de reuniões"
Munic_2014_Reuni <- select(Munic_2014,A1, Reuni_codigo)
### Excluir conselhos da alimentacao escolar, transporte escolar e defesa civil
Munic_2014_Reuni <- select(Munic_2014_Reuni, -c(A614, A622, A731))
# Solução simples # Introdução de NAs
Munic_2014_Reuni <- Munic_2014_Reuni %>%
mutate_if(is.factor, as.character) %>%
mutate_if(is.character, as.numeric)
## Warning: NAs introduced by coercion
## Warning: NAs introduced by coercion
## Warning: NAs introduced by coercion
## Warning: NAs introduced by coercion
## Warning: NAs introduced by coercion
## Warning: NAs introduced by coercion
## Warning: NAs introduced by coercion
## Warning: NAs introduced by coercion
## Warning: NAs introduced by coercion
## Warning: NAs introduced by coercion
## Warning: NAs introduced by coercion
## Warning: NAs introduced by coercion
## Warning: NAs introduced by coercion
## Warning: NAs introduced by coercion
glimpse(Munic_2014_Reuni)
## Observations: 5,570
## Variables: 15
## $ A1 <dbl> 110001, 110002, 110003, 110004, 110005, 110006, 110007, 1...
## $ A552 <dbl> 8, 9, 6, NA, 8, NA, NA, NA, 18, 0, 0, NA, NA, 12, 0, NA, ...
## $ A560 <dbl> NA, 2, NA, 8, 6, NA, NA, NA, NA, 12, NA, NA, NA, NA, NA, ...
## $ A594 <dbl> NA, 24, NA, 21, NA, NA, NA, 33, NA, 18, NA, 66, NA, NA, 1...
## $ A630 <dbl> 14, 16, 12, 12, 12, 12, 13, 14, 12, 10, 12, 12, 12, 8, 12...
## $ A640 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, 12, NA, NA, N...
## $ A648 <dbl> 2, 12, 4, 15, 4, 6, 8, 12, 13, 12, 12, 12, 12, 12, 12, 6,...
## $ A656 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ A664 <dbl> 1, 5, 0, 12, 3, NA, NA, 10, 0, 5, 8, 1, NA, 6, 12, NA, 12...
## $ A672 <dbl> NA, 0, NA, 10, NA, NA, NA, NA, NA, 10, NA, 12, NA, NA, NA...
## $ A680 <dbl> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, N...
## $ A688 <dbl> NA, 0, NA, 10, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA...
## $ A722 <dbl> 0, 7, NA, 2, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, ...
## $ A739 <dbl> 0, 12, NA, 0, NA, NA, NA, NA, 0, NA, 5, 0, 3, 0, NA, NA, ...
## $ A895 <dbl> 12, 18, 8, 18, 9, 7, 16, 12, 9, 8, 19, 6, 6, 2, 17, 3, 15...
descr::descr(Munic_2014_Reuni[2:15])
## A552 A560 A594 A630
## Min. : 0.000 Min. : 0.000 Min. : 0.000 Min. : 0.00
## 1st Qu.: 1.000 1st Qu.: 0.000 1st Qu.: 3.000 1st Qu.: 9.00
## Median : 3.000 Median : 4.000 Median : 6.000 Median :12.00
## Mean : 4.455 Mean : 5.304 Mean : 7.804 Mean :11.27
## 3rd Qu.: 6.000 3rd Qu.:10.000 3rd Qu.: 12.000 3rd Qu.:12.00
## Max. :60.000 Max. :60.000 Max. :120.000 Max. :96.00
## NA's :1832 NA's :4619 NA's :712 NA's :32
## A640 A648 A656 A664
## Min. : 0.000 Min. : 0.000 Min. : 0.000 Min. : 0.000
## 1st Qu.: 3.000 1st Qu.: 5.000 1st Qu.: 1.000 1st Qu.: 2.000
## Median : 8.000 Median : 8.000 Median : 6.000 Median : 5.000
## Mean : 7.763 Mean : 8.823 Mean : 6.487 Mean : 6.038
## 3rd Qu.:12.000 3rd Qu.: 12.000 3rd Qu.:12.000 3rd Qu.: 11.000
## Max. :34.000 Max. :288.000 Max. :24.000 Max. :112.000
## NA's :5253 NA's :157 NA's :5297 NA's :2175
## A672 A680 A688 A722
## Min. : 0.000 Min. : 0.000 Min. : 0.000 Min. : 0.000
## 1st Qu.: 1.000 1st Qu.: 1.000 1st Qu.: 0.000 1st Qu.: 0.000
## Median : 6.000 Median : 2.000 Median : 4.000 Median : 4.000
## Mean : 6.302 Mean : 4.905 Mean : 5.198 Mean : 4.969
## 3rd Qu.:12.000 3rd Qu.:10.000 3rd Qu.:10.000 3rd Qu.: 9.000
## Max. :58.000 Max. :14.000 Max. :48.000 Max. :24.000
## NA's :4489 NA's :5549 NA's :4974 NA's :4897
## A739 A895
## Min. : 0.000 Min. : 0.00
## 1st Qu.: 0.000 1st Qu.: 6.00
## Median : 2.000 Median : 11.00
## Mean : 3.843 Mean : 10.28
## 3rd Qu.: 6.000 3rd Qu.: 12.00
## Max. :24.000 Max. :150.00
## NA's :3955 NA's :36
boxplot(Munic_2014_Reuni[2:15]) # explorar
# Substituir outliers antes de somar o total por mun.
#Substituir 5% dos maiores outliers
# identificar outs.
out <- boxplot(Munic_2014_Reuni[2:15])$out
summary(out)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0 4.0 20.0 22.2 26.0 288.0
length(out) # 1141
## [1] 1141
# idenficar 5% dos outs.
5*length(out)/100 # 1141 casos, ~5% = 57 casos
## [1] 57.05
# Guardar 5% dos outliers - Valores máximos
out_5 <- tail(sort(out), 57)
out_5
## [1] 50 50 50 50 50 50 50 50 50 51 52 53 54 55 55 55 56
## [18] 56 58 60 60 60 60 60 63 64 66 66 67 69 75 88 88 88
## [35] 88 88 88 92 92 96 96 96 96 96 101 101 104 105 108 108 112
## [52] 114 120 123 150 193 288
length(out_5)
## [1] 57
summary(out_5) # valor mínimo 50; subtituir todos os valores maiores por este;
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 50.00 55.00 67.00 82.18 96.00 288.00
######## Aplicar exclusão de outliers
Munic_2014_Reuni <- Munic_2014_Reuni %>%
mutate_at( vars(2:15),~ifelse(.x %in% out_5, 50, .x))
boxplot(Munic_2014_Reuni[2:15])
summary(Munic_2014_Reuni) # Valor máximo 50;
## A1 A552 A560 A594
## Min. :110001 Min. : 0.000 Min. : 0.000 Min. : 0.000
## 1st Qu.:251213 1st Qu.: 1.000 1st Qu.: 0.000 1st Qu.: 3.000
## Median :314628 Median : 3.000 Median : 4.000 Median : 6.000
## Mean :325359 Mean : 4.452 Mean : 5.293 Mean : 7.667
## 3rd Qu.:411919 3rd Qu.: 6.000 3rd Qu.:10.000 3rd Qu.:12.000
## Max. :530010 Max. :50.000 Max. :50.000 Max. :50.000
## NA's :1832 NA's :4619 NA's :712
## A630 A640 A648 A656
## Min. : 0.00 Min. : 0.000 Min. : 0.000 Min. : 0.000
## 1st Qu.: 9.00 1st Qu.: 3.000 1st Qu.: 5.000 1st Qu.: 1.000
## Median :12.00 Median : 8.000 Median : 8.000 Median : 6.000
## Mean :11.25 Mean : 7.763 Mean : 8.716 Mean : 6.487
## 3rd Qu.:12.00 3rd Qu.:12.000 3rd Qu.:12.000 3rd Qu.:12.000
## Max. :50.00 Max. :34.000 Max. :50.000 Max. :24.000
## NA's :32 NA's :5253 NA's :157 NA's :5297
## A664 A672 A680 A688
## Min. : 0.000 Min. : 0.000 Min. : 0.000 Min. : 0.000
## 1st Qu.: 2.000 1st Qu.: 1.000 1st Qu.: 1.000 1st Qu.: 0.000
## Median : 5.000 Median : 6.000 Median : 2.000 Median : 4.000
## Mean : 5.994 Mean : 6.295 Mean : 4.905 Mean : 5.198
## 3rd Qu.:11.000 3rd Qu.:12.000 3rd Qu.:10.000 3rd Qu.:10.000
## Max. :50.000 Max. :50.000 Max. :14.000 Max. :48.000
## NA's :2175 NA's :4489 NA's :5549 NA's :4974
## A722 A739 A895
## Min. : 0.000 Min. : 0.000 Min. : 0.00
## 1st Qu.: 0.000 1st Qu.: 0.000 1st Qu.: 6.00
## Median : 4.000 Median : 2.000 Median :11.00
## Mean : 4.969 Mean : 3.843 Mean :10.23
## 3rd Qu.: 9.000 3rd Qu.: 6.000 3rd Qu.:12.00
## Max. :24.000 Max. :24.000 Max. :50.00
## NA's :4897 NA's :3955 NA's :36
## Somar
Reuni_pond <- Munic_2014_Reuni %>%
#mutate_all(funs(ifelse(.=="Não aplicável",NA,.)))%>%
mutate(Num_reunioes = rowSums(select(., -A1), na.rm = T))
###
descr::descr(Reuni_pond)
## A1 A552 A560 A594
## Min. :110001 Min. : 0.000 Min. : 0.000 Min. : 0.000
## 1st Qu.:251213 1st Qu.: 1.000 1st Qu.: 0.000 1st Qu.: 3.000
## Median :314628 Median : 3.000 Median : 4.000 Median : 6.000
## Mean :325359 Mean : 4.452 Mean : 5.293 Mean : 7.667
## 3rd Qu.:411919 3rd Qu.: 6.000 3rd Qu.:10.000 3rd Qu.:12.000
## Max. :530010 Max. :50.000 Max. :50.000 Max. :50.000
## NA's :1832 NA's :4619 NA's :712
## A630 A640 A648 A656
## Min. : 0.00 Min. : 0.000 Min. : 0.000 Min. : 0.000
## 1st Qu.: 9.00 1st Qu.: 3.000 1st Qu.: 5.000 1st Qu.: 1.000
## Median :12.00 Median : 8.000 Median : 8.000 Median : 6.000
## Mean :11.25 Mean : 7.763 Mean : 8.716 Mean : 6.487
## 3rd Qu.:12.00 3rd Qu.:12.000 3rd Qu.:12.000 3rd Qu.:12.000
## Max. :50.00 Max. :34.000 Max. :50.000 Max. :24.000
## NA's :32 NA's :5253 NA's :157 NA's :5297
## A664 A672 A680 A688
## Min. : 0.000 Min. : 0.000 Min. : 0.000 Min. : 0.000
## 1st Qu.: 2.000 1st Qu.: 1.000 1st Qu.: 1.000 1st Qu.: 0.000
## Median : 5.000 Median : 6.000 Median : 2.000 Median : 4.000
## Mean : 5.994 Mean : 6.295 Mean : 4.905 Mean : 5.198
## 3rd Qu.:11.000 3rd Qu.:12.000 3rd Qu.:10.000 3rd Qu.:10.000
## Max. :50.000 Max. :50.000 Max. :14.000 Max. :48.000
## NA's :2175 NA's :4489 NA's :5549 NA's :4974
## A722 A739 A895 Num_reunioes
## Min. : 0.000 Min. : 0.000 Min. : 0.00 Min. : 0.00
## 1st Qu.: 0.000 1st Qu.: 0.000 1st Qu.: 6.00 1st Qu.: 32.00
## Median : 4.000 Median : 2.000 Median :11.00 Median : 42.00
## Mean : 4.969 Mean : 3.843 Mean :10.23 Mean : 48.32
## 3rd Qu.: 9.000 3rd Qu.: 6.000 3rd Qu.:12.00 3rd Qu.: 57.00
## Max. :24.000 Max. :24.000 Max. :50.00 Max. :263.00
## NA's :4897 NA's :3955 NA's :36
descr::freq(as.factor(Reuni_pond$Num_reunioes))
## as.factor(Reuni_pond$Num_reunioes)
## Frequency Percent
## 0 1 0.01795
## 2 1 0.01795
## 3 2 0.03591
## 4 3 0.05386
## 6 2 0.03591
## 7 4 0.07181
## 8 7 0.12567
## 9 4 0.07181
## 10 2 0.03591
## 11 12 0.21544
## 12 12 0.21544
## 13 10 0.17953
## 14 14 0.25135
## 15 23 0.41293
## 16 29 0.52065
## 17 23 0.41293
## 18 35 0.62837
## 19 25 0.44883
## 20 54 0.96948
## 21 60 1.07720
## 22 75 1.34650
## 23 61 1.09515
## 24 75 1.34650
## 25 74 1.32855
## 26 106 1.90305
## 27 104 1.86715
## 28 126 2.26212
## 29 118 2.11849
## 30 140 2.51346
## 31 149 2.67504
## 32 120 2.15440
## 33 130 2.33393
## 34 134 2.40575
## 35 128 2.29803
## 36 184 3.30341
## 37 131 2.35189
## 38 150 2.69300
## 39 117 2.10054
## 40 139 2.49551
## 41 119 2.13645
## 42 142 2.54937
## 43 127 2.28007
## 44 128 2.29803
## 45 108 1.93896
## 46 108 1.93896
## 47 88 1.57989
## 48 109 1.95691
## 49 89 1.59785
## 50 99 1.77738
## 51 95 1.70557
## 52 101 1.81329
## 53 65 1.16697
## 54 79 1.41831
## 55 59 1.05925
## 56 70 1.25673
## 57 53 0.95153
## 58 81 1.45422
## 59 47 0.84381
## 60 49 0.87971
## 61 62 1.11311
## 62 40 0.71813
## 63 43 0.77199
## 64 48 0.86176
## 65 39 0.70018
## 66 37 0.66427
## 67 32 0.57451
## 68 34 0.61041
## 69 33 0.59246
## 70 30 0.53860
## 71 37 0.66427
## 72 31 0.55655
## 73 26 0.46679
## 74 26 0.46679
## 75 28 0.50269
## 76 25 0.44883
## 77 19 0.34111
## 78 25 0.44883
## 79 17 0.30521
## 80 12 0.21544
## 81 12 0.21544
## 82 13 0.23339
## 83 17 0.30521
## 84 18 0.32316
## 85 13 0.23339
## 86 13 0.23339
## 87 10 0.17953
## 88 17 0.30521
## 89 13 0.23339
## 90 15 0.26930
## 91 15 0.26930
## 92 11 0.19749
## 93 17 0.30521
## 94 11 0.19749
## 95 14 0.25135
## 96 7 0.12567
## 97 13 0.23339
## 98 8 0.14363
## 99 12 0.21544
## 100 9 0.16158
## 101 7 0.12567
## 102 8 0.14363
## 103 5 0.08977
## 104 10 0.17953
## 105 8 0.14363
## 106 5 0.08977
## 107 5 0.08977
## 108 9 0.16158
## 109 2 0.03591
## 110 14 0.25135
## 111 7 0.12567
## 112 4 0.07181
## 113 8 0.14363
## 114 12 0.21544
## 115 7 0.12567
## 116 3 0.05386
## 117 4 0.07181
## 118 2 0.03591
## 119 6 0.10772
## 120 7 0.12567
## 121 10 0.17953
## 122 3 0.05386
## 123 2 0.03591
## 124 2 0.03591
## 125 1 0.01795
## 126 4 0.07181
## 127 4 0.07181
## 128 5 0.08977
## 129 2 0.03591
## 130 2 0.03591
## 131 3 0.05386
## 132 2 0.03591
## 133 5 0.08977
## 134 4 0.07181
## 135 2 0.03591
## 136 5 0.08977
## 137 3 0.05386
## 138 5 0.08977
## 139 1 0.01795
## 140 2 0.03591
## 141 1 0.01795
## 142 1 0.01795
## 143 2 0.03591
## 144 3 0.05386
## 145 2 0.03591
## 146 3 0.05386
## 147 2 0.03591
## 148 2 0.03591
## 149 1 0.01795
## 150 2 0.03591
## 151 1 0.01795
## 152 3 0.05386
## 154 1 0.01795
## 155 2 0.03591
## 156 3 0.05386
## 158 2 0.03591
## 160 2 0.03591
## 163 1 0.01795
## 165 3 0.05386
## 166 2 0.03591
## 168 1 0.01795
## 170 2 0.03591
## 171 1 0.01795
## 172 2 0.03591
## 173 1 0.01795
## 175 1 0.01795
## 177 1 0.01795
## 180 1 0.01795
## 183 2 0.03591
## 188 1 0.01795
## 189 1 0.01795
## 191 1 0.01795
## 193 2 0.03591
## 194 1 0.01795
## 196 1 0.01795
## 197 1 0.01795
## 199 1 0.01795
## 201 2 0.03591
## 225 1 0.01795
## 237 1 0.01795
## 245 1 0.01795
## 247 1 0.01795
## 257 1 0.01795
## 263 1 0.01795
## Total 5570 100.00000
summary(Reuni_pond$Num_reunioes)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.00 32.00 42.00 48.32 57.00 263.00
##Adicionamos os valores na tabela "Fisca_Munic"
Reuni_Munic <- Fisca_Munic %>%
left_join(select(Reuni_pond, A1, Num_reunioes))
## Joining, by = "A1"
glimpse(Reuni_Munic)
## Observations: 5,570
## Variables: 17
## $ A1 <dbl> 110001, 110002, 110003, 110004, 110005, 110006,...
## $ A1a <dbl> 1100015, 1100023, 1100031, 1100049, 1100056, 11...
## $ B1 <chr> "ALTA FLORESTA DOESTE", "ARIQUEMES", "CABIXI", ...
## $ B2 <dbl> 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,...
## $ B3 <chr> "RO", "RO", "RO", "RO", "RO", "RO", "RO", "RO",...
## $ B4 <chr> "1 - Norte", "1 - Norte", "1 - Norte", "1 - Nor...
## $ B5 <chr> "4 - 20001 até 50000", "6 - 100001 até 500000",...
## $ B6 <dbl> 25578, 104401, 6355, 87226, 17986, 18817, 8842,...
## $ Porte_pop2010 <chr> "Pequeno II", "Médio", "Pequeno I", "Médio", "P...
## $ Pop_Total2010 <dbl> 24392, 90353, 6313, 78574, 17029, 18591, 8783, ...
## $ Num_conselhos <dbl> 7, 11, 5, 10, 6, 3, 3, 5, 6, 8, 6, 8, 4, 6, 6, ...
## $ Paridade <dbl> 5, 11, 5, 9, 6, 3, 3, 5, 5, 7, 6, 8, 4, 6, 5, 3...
## $ Deliberativos <dbl> 5, 11, 5, 9, 5, 2, 3, 5, 6, 4, 4, 8, 3, 5, 5, 5...
## $ Consultivos <dbl> 6, 10, 0, 4, 5, 2, 1, 5, 3, 7, 3, 4, 4, 4, 5, 3...
## $ Normativos <dbl> 1, 8, 0, 3, 6, 2, 1, 5, 1, 5, 1, 6, 1, 5, 5, 3,...
## $ Fiscalizadores <dbl> 2, 9, 4, 3, 4, 3, 2, 5, 3, 6, 4, 4, 2, 6, 5, 4,...
## $ Num_reunioes <dbl> 37, 105, 30, 108, 42, 25, 37, 81, 52, 75, 56, 1...
table_Num_Reuni <- Reuni_pond %>%
summarise_all(sum, na.rm = T)%>%
gather() %>%
arrange(desc(as.numeric(value)))
table_Num_Reuni
## # A tibble: 16 x 2
## key value
## <chr> <dbl>
## 1 A1 1812247557
## 2 Num_reunioes 269154
## 3 A630 62296
## 4 A895 56620
## 5 A648 47179
## 6 A594 37248
## 7 A664 20348
## 8 A552 16641
## 9 A672 6805
## 10 A739 6206
## 11 A560 5034
## 12 A722 3344
## 13 A688 3098
## 14 A640 2461
## 15 A656 1771
## 16 A680 103
write_excel_csv2(table_Num_Reuni, "table_Num_Reuni.csv")
09.07.19
########### POTENCIAL PARTICIPATIVO ################
### O objeto Reuni_munic contém o aglomerado dos conselhos com suas caracteristicas para cada municipio.
Distribuicao_conselhos <- Reuni_Munic
glimpse(Distribuicao_conselhos)
## Observations: 5,570
## Variables: 17
## $ A1 <dbl> 110001, 110002, 110003, 110004, 110005, 110006,...
## $ A1a <dbl> 1100015, 1100023, 1100031, 1100049, 1100056, 11...
## $ B1 <chr> "ALTA FLORESTA DOESTE", "ARIQUEMES", "CABIXI", ...
## $ B2 <dbl> 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,...
## $ B3 <chr> "RO", "RO", "RO", "RO", "RO", "RO", "RO", "RO",...
## $ B4 <chr> "1 - Norte", "1 - Norte", "1 - Norte", "1 - Nor...
## $ B5 <chr> "4 - 20001 até 50000", "6 - 100001 até 500000",...
## $ B6 <dbl> 25578, 104401, 6355, 87226, 17986, 18817, 8842,...
## $ Porte_pop2010 <chr> "Pequeno II", "Médio", "Pequeno I", "Médio", "P...
## $ Pop_Total2010 <dbl> 24392, 90353, 6313, 78574, 17029, 18591, 8783, ...
## $ Num_conselhos <dbl> 7, 11, 5, 10, 6, 3, 3, 5, 6, 8, 6, 8, 4, 6, 6, ...
## $ Paridade <dbl> 5, 11, 5, 9, 6, 3, 3, 5, 5, 7, 6, 8, 4, 6, 5, 3...
## $ Deliberativos <dbl> 5, 11, 5, 9, 5, 2, 3, 5, 6, 4, 4, 8, 3, 5, 5, 5...
## $ Consultivos <dbl> 6, 10, 0, 4, 5, 2, 1, 5, 3, 7, 3, 4, 4, 4, 5, 3...
## $ Normativos <dbl> 1, 8, 0, 3, 6, 2, 1, 5, 1, 5, 1, 6, 1, 5, 5, 3,...
## $ Fiscalizadores <dbl> 2, 9, 4, 3, 4, 3, 2, 5, 3, 6, 4, 4, 2, 6, 5, 4,...
## $ Num_reunioes <dbl> 37, 105, 30, 108, 42, 25, 37, 81, 52, 75, 56, 1...
# Criar valor de referência
Ref <- data.frame(A1 = "Ref", A1a = "Ref", B1 = "Ref", B2 = "Ref", B3 = "Ref", B4 = "Ref", B5 = "Ref", B6 = "Ref", Porte_pop2010 = "Ref", Pop_Total2010 = "Ref", Num_conselhos = 14, Paridade = 14, Deliberativos= 14, Consultivos =14, Normativos = 14, Fiscalizadores =14, Num_reunioes = 263)
Distribuicao_conselhos <- rbind(Distribuicao_conselhos, Ref)
## potencial participativo: valor ponderado a cada conselho.
# Como indicado no roteiro: 1 para cada conselho, 1 se paritário, 1 se deliberativo, 0.3 o resto.
# "Perfil do Conselho": descreve o a quatdade de conselhos e suas poderações
Potencial <- Distribuicao_conselhos%>%
mutate(Perfil_Conselho = Num_conselhos+Paridade+Deliberativos+0.33*Consultivos+0.33*Normativos+0.33*Fiscalizadores)
# índice participativo: Número de reuniões/Número de Conselhos (média das reuniões)
Potencial <- Potencial %>%
mutate(Indice_participativo = Num_reunioes/Num_conselhos)
glimpse(Potencial)
## Observations: 5,571
## Variables: 19
## $ A1 <chr> "110001", "110002", "110003", "110004", "...
## $ A1a <chr> "1100015", "1100023", "1100031", "1100049...
## $ B1 <chr> "ALTA FLORESTA DOESTE", "ARIQUEMES", "CAB...
## $ B2 <chr> "11", "11", "11", "11", "11", "11", "11",...
## $ B3 <chr> "RO", "RO", "RO", "RO", "RO", "RO", "RO",...
## $ B4 <chr> "1 - Norte", "1 - Norte", "1 - Norte", "1...
## $ B5 <chr> "4 - 20001 até 50000", "6 - 100001 até 50...
## $ B6 <chr> "25578", "104401", "6355", "87226", "1798...
## $ Porte_pop2010 <chr> "Pequeno II", "Médio", "Pequeno I", "Médi...
## $ Pop_Total2010 <chr> "24392", "90353", "6313", "78574", "17029...
## $ Num_conselhos <dbl> 7, 11, 5, 10, 6, 3, 3, 5, 6, 8, 6, 8, 4, ...
## $ Paridade <dbl> 5, 11, 5, 9, 6, 3, 3, 5, 5, 7, 6, 8, 4, 6...
## $ Deliberativos <dbl> 5, 11, 5, 9, 5, 2, 3, 5, 6, 4, 4, 8, 3, 5...
## $ Consultivos <dbl> 6, 10, 0, 4, 5, 2, 1, 5, 3, 7, 3, 4, 4, 4...
## $ Normativos <dbl> 1, 8, 0, 3, 6, 2, 1, 5, 1, 5, 1, 6, 1, 5,...
## $ Fiscalizadores <dbl> 2, 9, 4, 3, 4, 3, 2, 5, 3, 6, 4, 4, 2, 6,...
## $ Num_reunioes <dbl> 37, 105, 30, 108, 42, 25, 37, 81, 52, 75,...
## $ Perfil_Conselho <dbl> 19.97, 41.91, 16.32, 31.30, 21.95, 10.31,...
## $ Indice_participativo <dbl> 5.285714, 9.545455, 6.000000, 10.800000, ...
unique(Potencial$B5)
## [1] "4 - 20001 até 50000" "6 - 100001 até 500000" "2 - 5001 até 10000"
## [4] "5 - 50001 até 100000" "3 - 10001 até 20000" "7 - Maior que 500000"
## [7] "1 - Até 5000" "Ref"
# Potencial participativo = média de reuniões * perfil dos conselhos.
Potencial<- Potencial %>%
mutate(Potencial_participativo = Perfil_Conselho*Indice_participativo)
glimpse(Potencial)
## Observations: 5,571
## Variables: 20
## $ A1 <chr> "110001", "110002", "110003", "110004"...
## $ A1a <chr> "1100015", "1100023", "1100031", "1100...
## $ B1 <chr> "ALTA FLORESTA DOESTE", "ARIQUEMES", "...
## $ B2 <chr> "11", "11", "11", "11", "11", "11", "1...
## $ B3 <chr> "RO", "RO", "RO", "RO", "RO", "RO", "R...
## $ B4 <chr> "1 - Norte", "1 - Norte", "1 - Norte",...
## $ B5 <chr> "4 - 20001 até 50000", "6 - 100001 até...
## $ B6 <chr> "25578", "104401", "6355", "87226", "1...
## $ Porte_pop2010 <chr> "Pequeno II", "Médio", "Pequeno I", "M...
## $ Pop_Total2010 <chr> "24392", "90353", "6313", "78574", "17...
## $ Num_conselhos <dbl> 7, 11, 5, 10, 6, 3, 3, 5, 6, 8, 6, 8, ...
## $ Paridade <dbl> 5, 11, 5, 9, 6, 3, 3, 5, 5, 7, 6, 8, 4...
## $ Deliberativos <dbl> 5, 11, 5, 9, 5, 2, 3, 5, 6, 4, 4, 8, 3...
## $ Consultivos <dbl> 6, 10, 0, 4, 5, 2, 1, 5, 3, 7, 3, 4, 4...
## $ Normativos <dbl> 1, 8, 0, 3, 6, 2, 1, 5, 1, 5, 1, 6, 1,...
## $ Fiscalizadores <dbl> 2, 9, 4, 3, 4, 3, 2, 5, 3, 6, 4, 4, 2,...
## $ Num_reunioes <dbl> 37, 105, 30, 108, 42, 25, 37, 81, 52, ...
## $ Perfil_Conselho <dbl> 19.97, 41.91, 16.32, 31.30, 21.95, 10....
## $ Indice_participativo <dbl> 5.285714, 9.545455, 6.000000, 10.80000...
## $ Potencial_participativo <dbl> 105.55571, 400.05000, 97.92000, 338.04...
# Aplicar fórmula
#Normalizar
#(x-min(x))/(max(x)-min(x))
#Checar NAs
sapply(Potencial, function(x)all(any(is.na(x))))
## A1 A1a B1
## FALSE FALSE FALSE
## B2 B3 B4
## FALSE FALSE FALSE
## B5 B6 Porte_pop2010
## FALSE FALSE FALSE
## Pop_Total2010 Num_conselhos Paridade
## TRUE FALSE FALSE
## Deliberativos Consultivos Normativos
## FALSE FALSE FALSE
## Fiscalizadores Num_reunioes Perfil_Conselho
## FALSE FALSE FALSE
## Indice_participativo Potencial_participativo
## TRUE TRUE
sum(is.na(Potencial$Indice_participativo)) # Apenas 1 NA.
## [1] 1
## Remover Na's
Potencial <- Potencial %>%
mutate(IPP_Norm = round((Potencial$Potencial_participativo - min(Potencial$Potencial_participativo, na.rm = T))/(max(Potencial$Potencial_participativo, na.rm = T)- min(Potencial$Potencial_participativo, na.rm = T)),3))
glimpse(Potencial)
## Observations: 5,571
## Variables: 21
## $ A1 <chr> "110001", "110002", "110003", "110004"...
## $ A1a <chr> "1100015", "1100023", "1100031", "1100...
## $ B1 <chr> "ALTA FLORESTA DOESTE", "ARIQUEMES", "...
## $ B2 <chr> "11", "11", "11", "11", "11", "11", "1...
## $ B3 <chr> "RO", "RO", "RO", "RO", "RO", "RO", "R...
## $ B4 <chr> "1 - Norte", "1 - Norte", "1 - Norte",...
## $ B5 <chr> "4 - 20001 até 50000", "6 - 100001 até...
## $ B6 <chr> "25578", "104401", "6355", "87226", "1...
## $ Porte_pop2010 <chr> "Pequeno II", "Médio", "Pequeno I", "M...
## $ Pop_Total2010 <chr> "24392", "90353", "6313", "78574", "17...
## $ Num_conselhos <dbl> 7, 11, 5, 10, 6, 3, 3, 5, 6, 8, 6, 8, ...
## $ Paridade <dbl> 5, 11, 5, 9, 6, 3, 3, 5, 5, 7, 6, 8, 4...
## $ Deliberativos <dbl> 5, 11, 5, 9, 5, 2, 3, 5, 6, 4, 4, 8, 3...
## $ Consultivos <dbl> 6, 10, 0, 4, 5, 2, 1, 5, 3, 7, 3, 4, 4...
## $ Normativos <dbl> 1, 8, 0, 3, 6, 2, 1, 5, 1, 5, 1, 6, 1,...
## $ Fiscalizadores <dbl> 2, 9, 4, 3, 4, 3, 2, 5, 3, 6, 4, 4, 2,...
## $ Num_reunioes <dbl> 37, 105, 30, 108, 42, 25, 37, 81, 52, ...
## $ Perfil_Conselho <dbl> 19.97, 41.91, 16.32, 31.30, 21.95, 10....
## $ Indice_participativo <dbl> 5.285714, 9.545455, 6.000000, 10.80000...
## $ Potencial_participativo <dbl> 105.55571, 400.05000, 97.92000, 338.04...
## $ IPP_Norm <dbl> 0.095, 0.377, 0.087, 0.318, 0.141, 0.0...
sum(is.na(Potencial$IPP_Norm)) # apenas 1 NA
## [1] 1
Potencial %>%
arrange(desc(IPP_Norm))
## # A tibble: 5,571 x 21
## A1 A1a B1 B2 B3 B4 B5 B6 Porte_pop2010
## <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
## 1 Ref Ref Ref Ref Ref Ref Ref Ref Ref
## 2 3201~ 3201~ CARI~ 32 ES 3 - ~ 6 - ~ 3818~ Grande
## 3 4300~ 4300~ ALEG~ 43 RS 4 - ~ 5 - ~ 78499 Médio
## 4 3205~ 3205~ VITO~ 32 ES 3 - ~ 6 - ~ 3558~ Grande
## 5 3304~ 3304~ RIO ~ 33 RJ 3 - ~ 7 - ~ 6476~ Metrópole
## 6 4314~ 4314~ PORT~ 43 RS 4 - ~ 7 - ~ 1476~ Metrópole
## 7 1400~ 1400~ BOA ~ 14 RR 1 - ~ 6 - ~ 3207~ Grande
## 8 4202~ 4202~ BLUM~ 42 SC 4 - ~ 6 - ~ 3388~ Grande
## 9 3205~ 3205~ VILA~ 32 ES 3 - ~ 6 - ~ 4727~ Grande
## 10 2927~ 2927~ SALV~ 29 BA 2 - ~ 7 - ~ 2921~ Metrópole
## # ... with 5,561 more rows, and 12 more variables: Pop_Total2010 <chr>,
## # Num_conselhos <dbl>, Paridade <dbl>, Deliberativos <dbl>,
## # Consultivos <dbl>, Normativos <dbl>, Fiscalizadores <dbl>,
## # Num_reunioes <dbl>, Perfil_Conselho <dbl>, Indice_participativo <dbl>,
## # Potencial_participativo <dbl>, IPP_Norm <dbl>
summary(Potencial$IPP_Norm)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 0.0000 0.0980 0.1330 0.1529 0.1810 1.0000 1
descr(Potencial$IPP_Norm)
## Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
## 0.0000 0.0980 0.1330 0.1529 0.1810 1.0000 1
tail(sort(Potencial$IPP_Norm))
## [1] 0.716 0.717 0.764 0.768 0.825 1.000
head(sort(Potencial$IPP_Norm))
## [1] 0.000 0.003 0.003 0.004 0.005 0.005
#write_excel_csv2(Potencial, "Potencial_Ref_Final.csv")
# refirar valor de referência
Potencial <- filter(Potencial, IPP_Norm != 1)
# Classificação IPP-Norm
summary(Potencial$IPP_Norm)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0000 0.0980 0.1330 0.1527 0.1810 0.8250
p <- ggplot(Potencial, aes(x=1, y=IPP_Norm)) +
geom_boxplot()
ggplot_build(p)$data
## [[1]]
## ymin lower middle upper ymax
## 1 0 0.098 0.133 0.181 0.305
## outliers
## 1 0.377, 0.318, 0.354, 0.368, 0.308, 0.407, 0.307, 0.316, 0.358, 0.397, 0.330, 0.316, 0.478, 0.692, 0.483, 0.333, 0.376, 0.355, 0.550, 0.348, 0.320, 0.489, 0.310, 0.334, 0.364, 0.497, 0.349, 0.309, 0.347, 0.321, 0.309, 0.315, 0.366, 0.492, 0.379, 0.381, 0.313, 0.391, 0.453, 0.467, 0.319, 0.417, 0.313, 0.337, 0.348, 0.334, 0.541, 0.324, 0.310, 0.322, 0.340, 0.357, 0.604, 0.400, 0.466, 0.324, 0.409, 0.393, 0.328, 0.463, 0.481, 0.323, 0.335, 0.312, 0.345, 0.523, 0.358, 0.315, 0.452, 0.364, 0.372, 0.317, 0.471, 0.321, 0.396, 0.358, 0.598, 0.380, 0.413, 0.468, 0.354, 0.313, 0.361, 0.393, 0.342, 0.340, 0.647, 0.338, 0.453, 0.322, 0.442, 0.486, 0.641, 0.419, 0.360, 0.371, 0.397, 0.385, 0.385, 0.329, 0.572, 0.503, 0.455, 0.365, 0.324, 0.337, 0.536, 0.354, 0.409, 0.337, 0.331, 0.362, 0.320, 0.367, 0.575, 0.332, 0.402, 0.386, 0.307, 0.382, 0.491, 0.424, 0.357, 0.402, 0.825, 0.353, 0.313, 0.465, 0.521, 0.324, 0.568, 0.397, 0.674, 0.764, 0.381, 0.460, 0.449, 0.525, 0.307, 0.310, 0.373, 0.362, 0.399, 0.389, 0.345, 0.409, 0.344, 0.367, 0.344, 0.358, 0.369, 0.496, 0.355, 0.385, 0.717, 0.434, 0.462, 0.339, 0.355, 0.571, 0.350, 0.328, 0.325, 0.336, 0.357, 0.352, 0.329, 0.426, 0.341, 0.457, 0.341, 0.457, 0.476, 0.313, 0.325, 0.369, 0.345, 0.357, 0.312, 0.401, 0.329, 0.418, 0.310, 0.322, 0.395, 0.406, 0.438, 0.377, 0.409, 0.350, 0.309, 0.368, 0.399, 0.337, 0.316, 0.347, 0.442, 0.433, 0.309, 0.377, 0.387, 0.411, 0.478, 0.317, 0.463, 0.307, 0.323, 0.407, 0.377, 0.395, 0.464, 0.335, 0.351, 0.354, 0.385, 0.466, 0.400, 0.368, 0.579, 0.342, 0.457, 0.517, 0.503, 0.391, 0.452, 0.397, 0.362, 0.309, 0.310, 0.306, 0.352, 0.339, 0.501, 0.307, 0.317, 0.390, 0.389, 0.316, 0.542, 0.330, 0.334, 0.362, 0.383, 0.386, 0.309, 0.685, 0.348, 0.558, 0.380, 0.472, 0.542, 0.326, 0.316, 0.768, 0.313, 0.352, 0.357, 0.460, 0.312, 0.392, 0.404, 0.376, 0.306, 0.330, 0.607, 0.437, 0.422, 0.384, 0.371, 0.330, 0.335, 0.458, 0.367, 0.425, 0.447, 0.334, 0.334, 0.453, 0.582, 0.716, 0.455, 0.316, 0.401, 0.430, 0.441, 0.482, 0.366, 0.331, 0.372, 0.423, 0.374, 0.421, 0.333, 0.316, 0.386, 0.405, 0.358, 0.332, 0.373, 0.519, 0.455, 0.442, 0.440, 0.546, 0.383, 0.345, 0.378, 0.394, 0.383, 0.316, 0.430, 0.313, 0.319, 0.353, 0.578, 0.393, 0.318, 0.421, 0.551, 0.308, 0.411, 0.327, 0.319, 0.307, 0.404, 0.495, 0.312, 0.615
## notchupper notchlower x PANEL group ymin_final ymax_final xmin xmax
## 1 0.1347573 0.1312427 1 1 -1 0 0.825 0.625 1.375
## xid newx new_width weight colour fill size alpha shape linetype
## 1 1 1 0.75 1 grey20 white 0.5 NA 19 solid
p <- ggplot(Potencial, aes(x=1, y=IPP_Norm)) +
#stat_boxplot(geom = "errorbar", coef=3, width = 0.5)+
geom_boxplot(coef = 3)
ggplot_build(p)$data
## [[1]]
## ymin lower middle upper ymax
## 1 0 0.098 0.133 0.181 0.426
## outliers
## 1 0.478, 0.692, 0.483, 0.550, 0.489, 0.497, 0.492, 0.453, 0.467, 0.541, 0.604, 0.466, 0.463, 0.481, 0.523, 0.452, 0.471, 0.598, 0.468, 0.647, 0.453, 0.442, 0.486, 0.641, 0.572, 0.503, 0.455, 0.536, 0.575, 0.491, 0.825, 0.465, 0.521, 0.568, 0.674, 0.764, 0.460, 0.449, 0.525, 0.496, 0.717, 0.434, 0.462, 0.571, 0.457, 0.457, 0.476, 0.438, 0.442, 0.433, 0.478, 0.463, 0.464, 0.466, 0.579, 0.457, 0.517, 0.503, 0.452, 0.501, 0.542, 0.685, 0.558, 0.472, 0.542, 0.768, 0.460, 0.607, 0.437, 0.458, 0.447, 0.453, 0.582, 0.716, 0.455, 0.430, 0.441, 0.482, 0.519, 0.455, 0.442, 0.440, 0.546, 0.430, 0.578, 0.551, 0.495, 0.615
## notchupper notchlower x PANEL group ymin_final ymax_final xmin xmax
## 1 0.1347573 0.1312427 1 1 -1 0 0.825 0.625 1.375
## xid newx new_width weight colour fill size alpha shape linetype
## 1 1 1 0.75 1 grey20 white 0.5 NA 19 solid
##
Potencial <- Potencial %>%
mutate(IPP_Class = case_when(
IPP_Norm <= 0.097 ~ "muito baixo",
IPP_Norm >= 0.098 & IPP_Norm <= 0.132 ~ "baixo",
IPP_Norm >= 0.133 & IPP_Norm <= 0.180 ~ "médio",
IPP_Norm >= 0.181 & IPP_Norm <= 0.425 ~ "alto",
IPP_Norm >= 0.426 ~ "muito alto"))
glimpse(Potencial)
## Observations: 5,569
## Variables: 22
## $ A1 <chr> "110001", "110002", "110003", "110004"...
## $ A1a <chr> "1100015", "1100023", "1100031", "1100...
## $ B1 <chr> "ALTA FLORESTA DOESTE", "ARIQUEMES", "...
## $ B2 <chr> "11", "11", "11", "11", "11", "11", "1...
## $ B3 <chr> "RO", "RO", "RO", "RO", "RO", "RO", "R...
## $ B4 <chr> "1 - Norte", "1 - Norte", "1 - Norte",...
## $ B5 <chr> "4 - 20001 até 50000", "6 - 100001 até...
## $ B6 <chr> "25578", "104401", "6355", "87226", "1...
## $ Porte_pop2010 <chr> "Pequeno II", "Médio", "Pequeno I", "M...
## $ Pop_Total2010 <chr> "24392", "90353", "6313", "78574", "17...
## $ Num_conselhos <dbl> 7, 11, 5, 10, 6, 3, 3, 5, 6, 8, 6, 8, ...
## $ Paridade <dbl> 5, 11, 5, 9, 6, 3, 3, 5, 5, 7, 6, 8, 4...
## $ Deliberativos <dbl> 5, 11, 5, 9, 5, 2, 3, 5, 6, 4, 4, 8, 3...
## $ Consultivos <dbl> 6, 10, 0, 4, 5, 2, 1, 5, 3, 7, 3, 4, 4...
## $ Normativos <dbl> 1, 8, 0, 3, 6, 2, 1, 5, 1, 5, 1, 6, 1,...
## $ Fiscalizadores <dbl> 2, 9, 4, 3, 4, 3, 2, 5, 3, 6, 4, 4, 2,...
## $ Num_reunioes <dbl> 37, 105, 30, 108, 42, 25, 37, 81, 52, ...
## $ Perfil_Conselho <dbl> 19.97, 41.91, 16.32, 31.30, 21.95, 10....
## $ Indice_participativo <dbl> 5.285714, 9.545455, 6.000000, 10.80000...
## $ Potencial_participativo <dbl> 105.55571, 400.05000, 97.92000, 338.04...
## $ IPP_Norm <dbl> 0.095, 0.377, 0.087, 0.318, 0.141, 0.0...
## $ IPP_Class <chr> "muito baixo", "alto", "muito baixo", ...
Potencial$IPP_Class <- factor(Potencial$IPP_Class, levels = c("muito alto", "alto", "médio", "baixo", "muito baixo"))
unique(Potencial$IPP_Class)
## [1] muito baixo alto médio baixo muito alto
## Levels: muito alto alto médio baixo muito baixo
sum(is.na(Potencial$IPP_Class))
## [1] 0
X11()
grid.arrange(hist_1, hist_2, hist_3, hist_4,
hist_5, hist_6, nrow = 2)
## Warning: Removed 2 rows containing missing values (geom_bar).
## Warning: Removed 2 rows containing missing values (geom_bar).
## Warning: Removed 2 rows containing missing values (geom_bar).
Potencial <- mutate(Potencial, A1 = as.numeric(A1))
Potencial_idh <- Potencial %>%
full_join(idh, by = c("A1" = "Codmun6"))
glimpse(Potencial_idh)
## Observations: 5,570
## Variables: 23
## $ A1 <dbl> 110001, 110002, 110003, 110004, 110005...
## $ A1a <chr> "1100015", "1100023", "1100031", "1100...
## $ B1 <chr> "ALTA FLORESTA DOESTE", "ARIQUEMES", "...
## $ B2 <chr> "11", "11", "11", "11", "11", "11", "1...
## $ B3 <chr> "RO", "RO", "RO", "RO", "RO", "RO", "R...
## $ B4 <chr> "1 - Norte", "1 - Norte", "1 - Norte",...
## $ B5 <chr> "4 - 20001 até 50000", "6 - 100001 até...
## $ B6 <chr> "25578", "104401", "6355", "87226", "1...
## $ Porte_pop2010 <chr> "Pequeno II", "Médio", "Pequeno I", "M...
## $ Pop_Total2010 <chr> "24392", "90353", "6313", "78574", "17...
## $ Num_conselhos <dbl> 7, 11, 5, 10, 6, 3, 3, 5, 6, 8, 6, 8, ...
## $ Paridade <dbl> 5, 11, 5, 9, 6, 3, 3, 5, 5, 7, 6, 8, 4...
## $ Deliberativos <dbl> 5, 11, 5, 9, 5, 2, 3, 5, 6, 4, 4, 8, 3...
## $ Consultivos <dbl> 6, 10, 0, 4, 5, 2, 1, 5, 3, 7, 3, 4, 4...
## $ Normativos <dbl> 1, 8, 0, 3, 6, 2, 1, 5, 1, 5, 1, 6, 1,...
## $ Fiscalizadores <dbl> 2, 9, 4, 3, 4, 3, 2, 5, 3, 6, 4, 4, 2,...
## $ Num_reunioes <dbl> 37, 105, 30, 108, 42, 25, 37, 81, 52, ...
## $ Perfil_Conselho <dbl> 19.97, 41.91, 16.32, 31.30, 21.95, 10....
## $ Indice_participativo <dbl> 5.285714, 9.545455, 6.000000, 10.80000...
## $ Potencial_participativo <dbl> 105.55571, 400.05000, 97.92000, 338.04...
## $ IPP_Norm <dbl> 0.095, 0.377, 0.087, 0.318, 0.141, 0.0...
## $ IPP_Class <fct> muito baixo, alto, muito baixo, alto, ...
## $ IDHM <dbl> 0.641, 0.702, 0.650, 0.718, 0.692, 0.6...
Potencial_idh$IPP_Class <- factor(Potencial_idh$IPP_Class, levels = c("muito alto", "alto", "médio", "baixo", "muito baixo"))
Potencial_idh$Porte_pop2010 <- factor(Potencial_idh$Porte_pop2010, levels = c("Metrópole", "Grande", "Médio", "Pequeno II", "Pequeno I"))
# Classificação IDH-M
Potencial_idh <- Potencial_idh %>%
mutate(IDHM_Class = case_when(
IDHM <= 0.499 ~ "muito baixo",
IDHM >= 0.500 & IDHM <= 0.599 ~ "baixo",
IDHM >= 0.600 & IDHM <= 0.699 ~ "médio",
IDHM >= 0.700 & IDHM <= 0.799 ~ "alto",
IDHM >= 0.800 ~ "muito alto"))
Potencial_idh$IDHM_Class <- factor(Potencial_idh$IDHM_Class, levels = c("muito alto", "alto", "médio", "baixo", "muito baixo"))
sum(is.na(Potencial_idh$IDHM_Class))
## [1] 5
# Organizar
Potencial_idh <- Potencial_idh %>%
select(1:10, 23,24, 11:22)
glimpse(Potencial_idh)
## Observations: 5,570
## Variables: 24
## $ A1 <dbl> 110001, 110002, 110003, 110004, 110005...
## $ A1a <chr> "1100015", "1100023", "1100031", "1100...
## $ B1 <chr> "ALTA FLORESTA DOESTE", "ARIQUEMES", "...
## $ B2 <chr> "11", "11", "11", "11", "11", "11", "1...
## $ B3 <chr> "RO", "RO", "RO", "RO", "RO", "RO", "R...
## $ B4 <chr> "1 - Norte", "1 - Norte", "1 - Norte",...
## $ B5 <chr> "4 - 20001 até 50000", "6 - 100001 até...
## $ B6 <chr> "25578", "104401", "6355", "87226", "1...
## $ Porte_pop2010 <fct> Pequeno II, Médio, Pequeno I, Médio, P...
## $ Pop_Total2010 <chr> "24392", "90353", "6313", "78574", "17...
## $ IDHM <dbl> 0.641, 0.702, 0.650, 0.718, 0.692, 0.6...
## $ IDHM_Class <fct> médio, alto, médio, alto, médio, médio...
## $ Num_conselhos <dbl> 7, 11, 5, 10, 6, 3, 3, 5, 6, 8, 6, 8, ...
## $ Paridade <dbl> 5, 11, 5, 9, 6, 3, 3, 5, 5, 7, 6, 8, 4...
## $ Deliberativos <dbl> 5, 11, 5, 9, 5, 2, 3, 5, 6, 4, 4, 8, 3...
## $ Consultivos <dbl> 6, 10, 0, 4, 5, 2, 1, 5, 3, 7, 3, 4, 4...
## $ Normativos <dbl> 1, 8, 0, 3, 6, 2, 1, 5, 1, 5, 1, 6, 1,...
## $ Fiscalizadores <dbl> 2, 9, 4, 3, 4, 3, 2, 5, 3, 6, 4, 4, 2,...
## $ Num_reunioes <dbl> 37, 105, 30, 108, 42, 25, 37, 81, 52, ...
## $ Perfil_Conselho <dbl> 19.97, 41.91, 16.32, 31.30, 21.95, 10....
## $ Indice_participativo <dbl> 5.285714, 9.545455, 6.000000, 10.80000...
## $ Potencial_participativo <dbl> 105.55571, 400.05000, 97.92000, 338.04...
## $ IPP_Norm <dbl> 0.095, 0.377, 0.087, 0.318, 0.141, 0.0...
## $ IPP_Class <fct> muito baixo, alto, muito baixo, alto, ...
Potencial_idh <- descr::toUTF8(Potencial_idh)
#write_excel_csv2(Potencial_idh, "Ranking.final_julho_2.csv")
# Histogram
hist_8 <- ggplot(Potencial_idh, aes(IPP_Norm)) +
geom_histogram(binwidth = 0.001) +
#ggtitle("IPPC Normalizado")+
ylab("Count") + xlab("")+
scale_x_continuous(breaks = c(0,.2, .4, .6,.8, 1), limits = c(0,1))+
theme_classic()+
theme_BOX
hist_8
## Warning: Removed 1 rows containing non-finite values (stat_bin).
## Warning: Removed 2 rows containing missing values (geom_bar).
#
box_IPP <- ggplot(Potencial_idh, aes(x=1, y=IPP_Norm)) +
stat_boxplot(geom = "errorbar", coef=3, width = 0.5)+
geom_boxplot(coef = 3)+
ylab("Normalized IPPC") + xlab("") +
scale_y_continuous(breaks = c(0,.2, .4, .6,.8, 1), limits = c(0,1))+
#theme(axis.text.x = element_blank())+
coord_flip()+
theme_classic()+
theme_BOX+
theme(axis.text.y = element_blank())
box_IPP
## Warning: Removed 1 rows containing non-finite values (stat_boxplot).
## Warning: Removed 1 rows containing non-finite values (stat_boxplot).
x11()
cowplot::plot_grid(hist_8, box_IPP, nrow=2, align = "v", rel_heights = (c(2,1)))
## Warning: Removed 1 rows containing non-finite values (stat_bin).
## Warning: Removed 2 rows containing missing values (geom_bar).
## Warning: Removed 1 rows containing non-finite values (stat_boxplot).
## Warning: Removed 1 rows containing non-finite values (stat_boxplot).
idh_ipp_reg <- ggplot(drop_na(Potencial_idh),
aes(x=IDHM, y=IPP_Norm ))+
geom_point()+
#scale_fill_manual(values = color, name = "Região" )+
#ggtitle("IPPC por IDHM e região")+
xlab("MHDI") + ylab("IPPC")+
geom_smooth(se=F)+
theme_classic()+
theme_hist
#dev.off()
X11()
idh_ipp_reg
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
# Salvar PNG com tamanho widht = 900 e heigth = 400
index_ano <- str_which(Legenda_Munic_2014$V4,"ano de criação")
### Usar o índice para selecionar as linhas.
ano_lista <- slice(Legenda_Munic_2014,index_ano)
## Usar a coluna V17 que possui os códigos da base de dados
ano_codigo <- ano_lista$V17 #identificamos os códigos de cada conselho
##Selecionamos apenas as colunas correspondentes "ano"
Munic_2014_anos <- select(Munic_2014, A1, ano_codigo)
Munic_2014_anos <- gather(Munic_2014_anos, conselhos, anos, -A1)
Munic_2014_anos <- Munic_2014_anos %>%
mutate(anos = as.numeric(anos)) %>%
mutate(conselhos = factor(conselhos)) %>%
drop_na()
## Warning: NAs introduced by coercion
#Munic_2014_anos$conselhos
dput(unique(Munic_2014_anos$conselhos))
## structure(1:18, .Label = c("A546", "A554", "A588", "A605", "A608",
## "A616", "A624", "A634", "A642", "A650", "A658", "A666", "A674",
## "A682", "A716", "A725", "A733", "A892"), class = "factor")
labels <- c("A546" = "Environment (3.785)",
"A554"= "Women's rights (976)",
"A588" = "Education (4.874)",
"A624" = "Health care (5.556)",
"A634" = "Human rights (323)",
"A642" = "Children & Adolescents' rights (5.481)",
"A650" = "Racial equality (280)",
"A658" = "Seniors' rights (3.450)",
"A666" = "Rights of persons with disabilities (1.093)",
"A674" = "LGBTT (21)",
"A682" = "Youth (608)",
"A716" = "Public security (691)",
"A733" = "Food security (1.629)",
"A892" = "Welfare (5.562)") #"A914" = "Seg. Alimentar" # "A605" = "C. Fundeb" # "A608" = "Aliment. Escolar" # , "A616" = "Trans. Escolar" #"A725" = "Def. Civil",
#labels <- c("A546" = "Meio Ambiente (3.785)", "A554"= "Mulheres (976)", "A588" = "Educação (4.874)", "A624" = "Saúde (5.556)", "A634" = "D. Humanos (323)", "A642" = "D. Crian/Adoles (5.481)", "A650" = "Ig. Racial (280)", "A658" = "D. Idoso (3.450)", "A666" = "D. Pess. Deficiente (1.093)", "A674" = "LGBTT (21)", "A682" = "Juventude (608)", "A716" = "S. Pública (691)", "A733" = "Seg. Alimentar (1.629)", "A892" = "Ass. Social (5.562)") #"A914" = "Seg.
Munic_2014_anos_88 <- Munic_2014_anos %>% filter(anos > 1987) %>%
filter(anos < 2015) %>%
filter(conselhos != "A605") %>%
droplevels()
tail(sort(Munic_2014_anos_88$anos))
## [1] 2014 2014 2014 2014 2014 2014
Munic_2014_anos_88 <- Munic_2014_anos_88 %>%
arrange(anos)
excluir <- c("A608", "A616", "A725")
Munic_2014_anos_88 <- Munic_2014_anos_88 %>%
filter(!(conselhos %in% excluir)) %>%
droplevels()
#Munic_2014_anos_88$conselhos
######
anos <- ggplot(Munic_2014_anos_88, aes(x=anos, y=reorder(conselhos, -anos, FUN = mean)))+
geom_density_ridges(aes(fill=reorder(conselhos, -anos, FUN = mean)), show.legend = F, alpha = .7) +
scale_fill_viridis_d(option = "B", direction = -1,
begin = .1, end = .9)+
scale_x_continuous(limits = c(1988, 2018),
breaks = c(1990, 1994, 1998, 2002, 2006, 2010, 2014))+
scale_y_discrete(labels = c(labels))+
geom_vline(xintercept = c(1990, 1994, 1998, 2002, 2006, 2010, 2014), linetype= "dotdash") +
ylab("") + xlab("")+
theme_classic()+
theme(axis.text.x = element_text(size = 14, face = "bold"),
axis.text.y = element_text(size = 14, face = "bold"))
x11() # Ajustar tamanho;
anos
## Picking joint bandwidth of 1.09