Created
July 22, 2022 20:58
-
-
Save fernandobarbalho/bc7a2f8093a82c3d86c1cc78dbac6127 to your computer and use it in GitHub Desktop.
Consumo de dados sobre gstos em assistência hospitalar e ambulatorial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(siconfiBD) | |
library(geobr) | |
library("basedosdados") | |
library(tidyverse) | |
library(colorspace) | |
siconfiBD::setup_siconfi(project_id = <seu_projeto>) | |
#Busca de dados de população de municípios | |
pop_municipios <- bdplyr("br_ibge_populacao.municipio") | |
pop_municipios <- | |
pop_municipios%>% | |
filter(ano==2020)%>% | |
bd_collect() | |
gastos_hospitais_pc<- | |
pop_municipios %>% | |
left_join(gastos_hospitais_perc) %>% | |
mutate(perc= ifelse(is.na(perc),0,perc), | |
gasto_pc= valor/populacao, | |
gasto_pc = ifelse(is.na(gasto_pc),0,gasto_pc)) | |
library(ggrepel) | |
library(sf) | |
municipios %>% | |
inner_join( | |
gastos_hospitais_pc %>% | |
filter(sigla_uf %in% c("CE")) %>% | |
mutate(code_muni = as.numeric(id_municipio)) | |
) %>% | |
ggplot()+ | |
geom_sf(aes(fill=gasto_pc), alpha= 1, color= "lightgray")+ #, text=name_muni | |
geom_text_repel(data=mun_sel[1,], aes(x= -39.3445, | |
y=-7.403116, | |
label=name_muni, | |
color = gasto_pc), | |
#color = "white", | |
show.legend = FALSE, | |
fontface = "bold", | |
size=2.5, | |
nudge_x = c(-0.40), | |
nudge_y = c(-0.25))+ | |
geom_text_repel(data=mun_sel[2,], aes(x= -38.52775, | |
y=-3.785651, | |
label=name_muni, | |
color= gasto_pc ), | |
show.legend = FALSE, | |
fontface = "bold", | |
size=2.5, | |
nudge_x = c(0.6), | |
nudge_y = c(0))+ | |
labs( title = "Gastos em Assistência Hospitalar e Ambulatorial", | |
subtitle= "Municípios do berço da civilização (Ceará)", | |
fill=str_wrap("gasto per capita",10)) + | |
colorspace::scale_fill_continuous_sequential(palette = "PinkYl")+ | |
colorspace::scale_color_continuous_sequential(palette = "PinkYl")+ | |
theme_light() + | |
theme( | |
axis.text = element_blank(), | |
axis.title = element_blank(), | |
panel.background = element_rect(fill = "#15202B"), | |
panel.grid = element_blank(), | |
) | |
municipios %>% | |
inner_join( | |
gastos_hospitais_pc %>% | |
filter(sigla_uf %in% c("CE")) %>% | |
mutate(code_muni = as.numeric(id_municipio)) | |
) %>% | |
ggplot()+ | |
geom_sf(aes(fill=perc), alpha= 1, color= "lightgray")+ #, text=name_muni | |
geom_text_repel(data=mun_sel[1,], aes(x= -39.3445, | |
y=-7.403116, | |
label=name_muni, | |
color = perc), | |
show.legend = FALSE, | |
fontface = "bold", | |
size=2.5, | |
nudge_x = c(-0.40), | |
nudge_y = c(-0.25))+ | |
geom_text_repel(data=mun_sel[2,], aes(x= -38.52775, | |
y=-3.785651, | |
label=name_muni, | |
color= perc ), | |
show.legend = FALSE, | |
fontface = "bold", | |
size=2.5, | |
nudge_x = c(0.6), | |
nudge_y = c(0))+ | |
labs( title = "Gastos em Assistência Hospitalar e Ambulatorial", | |
subtitle= "Municípios do berço da civilização (Ceará)", | |
fill=str_wrap("(%) gasto total",10)) + | |
colorspace::scale_fill_continuous_sequential(palette = "PinkYl")+ | |
colorspace::scale_color_continuous_sequential(palette = "PinkYl")+ | |
theme_light() + | |
theme( | |
axis.text = element_blank(), | |
axis.title = element_blank(), | |
panel.background = element_rect(fill = "#15202B"), | |
panel.grid = element_blank(), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment