Produzido por:

Juliana Angelo

Kayo Fernando

Mateus Elias

1 Definição dos tópicos que serão abordados

1.1 Tópico 1

Municípios que estão presentes no Consórcio

Foi criado um arquivo em excel (ConsorciosMT.xlsx) que tem os 141 municípios de Mato Grosso, seus respectivos consórcios de desenvolvimento econômico,latitude e longitude.Para poder facilitar na produção de mapas interativos,gráficos e tabelas que será produzido no dashboard dinâmico.

1.1.1 Arquivo ConsorciosMT

1.2 Tópico 2

PIB Regional e sua Composição

  • VAB1 - Agropecuária

  • VAB - Indústria

  • VAB - Serviços

1 VAB : Valor adicionado Bruto

1.4 Tópico 4

Quantidade de Meis

1.5 Tópico 5

Pessoal Ocupado

1.6 Tópico 6

Estimativa Populacional

2 Definição da fonte de dados que será utilizada

Tópico 2 - Tabela 5938 - Sidra IBGE

Tópico 3 - Para Produção Agrária iremos utilizar a Tabela 5457 - Sidra IBGE(PAM) e para Pecuária duas tabelas:

  1. Tabela 74 - Sidra IBGE(PPM)

  2. Tabela 3940 - Sidra IBGE(PPM)

Tópico 4 - Para Quantidade de Meis por gênero iremos utilizar o Portal do empreendedor e para a série histórica dos Meis iremos utilizar Simples Nacional.

Tópico 5 - Microdados RAIS/CAGED

Para baixar os dados do RAIS/CAGED é necessário ter o programa FileZilla.

Tópico 6 - EstimaPOP/Tabela 6579 - Sidra IBGE

Tópico 7 - Atlas Brasil

Fazer a consulta pela tabela

3 Construindo o Dashboard Dinâmico

3.1 Tópico 2 (Painel Pib)

3.1.1 Iniciando um novo documento em rmarkdown(template: flexdashboard)

knitr::include_graphics("panorama2.png") 

## Instale o pacote flexdashboard

##install.packages("flexdashboard")
knitr::include_graphics("panorama1.png") ## pacote knitr para carregar imagens

## Acesse file → New File → Rmarkdown
knitr::include_graphics("panorama3.png") 

## Em From Template escolha a opção Flex Dashboard
knitr::include_graphics("panorama4.png") 

## Template do Flex Dashboard no Rstudio
knitr::include_graphics("panorama5.png") 

## Vamos salvar o Arquivo com um nome, por exemplo "testedashboard"

## aperte o botão Knit para rodar o arquivo em html
knitr::include_graphics("panorama6.png") 

## saída do programa em HTML

3.1.2 Fazendo algumas alterações no arquivo.rmd

  • Cabeçalho

    title: “Panorama MT” (Nomenclatura do nosso Dashboard)

    output:

    flexdashboard::flex_dashboard:

    navbar:

    orientation: columns

    vertical_layout: fill

    runtime: shiny (Para deixar o nosso dashboard interativo)

  • Vamos Carregar agora os pacotes necessários para rodar o nosso dashboard

library(flexdashboard) # template do nosso dashboard
library(plotly) # gráficos interativos
library(rmarkdown)
library(readxl) #leitura de arquivos em excel
library(knitr) # leitura de imagens
library(ggthemes) # temas para gráficos ggplot2
library(shiny) # criação de dashboard dinamico
library(DT) #construção de tabelas
library(readr)# leitura de arquivos csv txt
library(dplyr) # manipulação de dados
library(rsconnect) 
library(leaflet) # mapas interativos
library(RColorBrewer) # paleta de cores para o mapa
library(ggplot2)# construção de gráficos
library(plyr)
library(kableExtra) #tabelas
library(DT)
library(rgdal)   # para carregar o shape
library(rgdal) # leitura do shape
library(PROJ)
library(blob)
library(dbplyr)
library(fs)
library(modelr)
library(proj4)
library(reprex)
library(whisker)
library(descr)

3.1.2.1 Criando um Mapa Interativo

shape<- readOGR("MT_Municipios_2019.shp", stringsAsFactors=FALSE, encoding="UTF-8")
## Warning in OGRSpatialRef(dsn, layer, morphFromESRI =
## morphFromESRI, dumpSRS = dumpSRS, : Discarded datum
## Sistema_de_Referencia_Geocentrico_para_las_AmericaS_2000 in Proj4 definition:
## +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs
## OGR data source with driver: ESRI Shapefile 
## Source: "C:\Users\mateusbarbosa\Documents\MT_Municipios_2019.shp", layer: "MT_Municipios_2019"
## with 141 features
## It has 4 fields
municipios<- read_excel("topico2.xlsx")

municipios2<-sprintf("R$ %.2f", municipios$pib)

municipios3<-sprintf("R$ %.2f", municipios$VABagro)

municipios3a<-sprintf("R$ %.2f", municipios$VABIndustria)

municipios3b <- sprintf("R$ %.2f", municipios$VABServicos)



municipios4<-cbind(municipios,municipios2)

municipios5<-cbind(municipios4,municipios3,municipios3a,municipios3b)

sojamt <-format(municipios5$soja, nsmall=2, big.mark=".")
## Warning in prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3L, :
## 'big.mark' and 'decimal.mark' are both '.', which could be confusing
municipios5<-cbind(municipios4,municipios3,municipios3a,municipios3b,sojamt)

municipios <- as.data.frame(municipios5)



municipiosmt <- merge(shape,municipios, by.x = "CD_MUN", by.y = "codigo_ibge")
  • Mapa do Painel PIB
library(maptools)
## Warning: package 'maptools' was built under R version 4.0.5
## Checking rgeos availability: TRUE
library(maps)
## Warning: package 'maps' was built under R version 4.0.5
## 
## Attaching package: 'maps'
## The following object is masked from 'package:plyr':
## 
##     ozone
## The following object is masked from 'package:purrr':
## 
##     map
library(dplyr)
library(RColorBrewer)
library(rgdal)
library(readr)
library(descr)


pal <- colorNumeric(
  palette = "Accent",
  domain = municipiosmt$cores)
municipiosmt$labels <- paste0("<strong> Municipio: </strong>", 
                     municipiosmt$nome, 
                     "<br><strong> Consórcio: </strong>", 
                     municipiosmt$consorcio,
                      "<br><strong> PIB: </strong>", 
                     municipiosmt$municipios2,
                      "<br><strong> VAB Indústria: </strong>", 
                     municipiosmt$municipios3a,
                      "<br><strong> VAB Serviços: </strong>", 
                     municipiosmt$municipios3b,
                     "<br><strong> VAB Agropecuária: </strong>", 
                     municipiosmt$municipios3)%>%
  
             lapply(htmltools::HTML)

leaflet(municipiosmt) %>%
        addProviderTiles("OpenStreetMap") %>% 
   

  addPolygons(fillColor = ~pal(municipiosmt$cores), 
              smoothFactor = 0.5,
              fillOpacity = 0.8,
              weight = 1,
               color = "white",
               label = ~labels,
              highlight = highlightOptions(
      color = "white",
      bringToFront = TRUE
              ))