R Markdown

library(readxl)
## Warning: package 'readxl' was built under R version 4.2.3
BasesMunicipios <- read_excel("C:/Users/17988111701/Desktop/Base_de_dados-master/BasesMunicipios.xlsx")
View(BasesMunicipios)
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.2.3
library(geobr)
## Warning: package 'geobr' was built under R version 4.2.3
## Loading required namespace: sf
library(dplyr)
## Warning: package 'dplyr' was built under R version 4.2.3
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(RColorBrewer)
library(sf)
## Warning: package 'sf' was built under R version 4.2.3
## Linking to GEOS 3.9.3, GDAL 3.5.2, PROJ 8.2.1; sf_use_s2() is TRUE
library(plotly)
## Warning: package 'plotly' was built under R version 4.2.3
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
desenho_municipios = read_municipality(code_muni = "RJ", showProgress = FALSE)
## Using year 2010
class(BasesMunicipios)
## [1] "tbl_df"     "tbl"        "data.frame"
class(desenho_municipios)
## [1] "sf"         "data.frame"
plot(desenho_municipios)

class(desenho_municipios$code_muni)
## [1] "numeric"
class(BasesMunicipios$`COD IBGE`)
## [1] "numeric"
BasesMunicipios$`COD IBGE2` = as.numeric(BasesMunicipios$`COD IBGE2`)


BasesMunicipios1 <-desenho_municipios %>% left_join(BasesMunicipios, by = c( "code_muni"="COD IBGE2"))


summary(BasesMunicipios1$Esperancadevida)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   71.93   73.26   73.74   73.96   74.83   76.27
mapa3 = ggplot() + 
  geom_sf(data=BasesMunicipios1, aes(fill=Esperancadevida)) +
  scale_fill_distiller(palette = "green", direction = 1, name="esperança de vida ao nascer",
                       limits = c(71,77))
## Warning in pal_name(palette, type): Unknown palette green
ggplotly(mapa3)
##hipoteses

## hipotese 1 : A região Norte/Nordeste do Estado do Rio de Janeiro possui menor esperança de vida ao nascer do que a região Sul-Sudoeste.

##hipotese 2 : A região metropolitana do RJ possui maior esperança de vida ao nascer do que as demais regiões, no tanto existem intraregiões que possuem uma esperança de vida mais alta assim como a região metropolitana.

##hipotese 3 : Os municipios industrializados são os que possuem uma melhor qualidade de vida e possuem, também, uma maior esperança de vida ao nascer do que os demais municipios.