Muerte materna - Amazonas (CDC-REUNIS)

DATA COMPLETA:

Limpieza de datos

library(dplyr)
## 
## 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
data<-subset(data, select = c(2:9))
names(data)[names(data) == "Ano"] <- "Año"
names(data)[names(data) == "Mmaterna1"] <- "MM_directa"
names(data)[names(data) == "Mmaterna2"] <- "MM_indirecta"
names(data)[names(data) == "provincia"] <- "Provincia"
names(data)[names(data) == "Muerte Mat"] <- "MM_total"
data <- mutate_all(data, ~replace(., is.na(.), 0))
data$Semana[data$Semana==0]=NA
data$Año<-as.factor(data$Año)

Análisis descriptivo de Amazonas

Aggregating por año

data1=aggregate(cbind(MM_directa, MM_indirecta, MM_total) ~ Año, data = data, sum)

Tabla: Total de muertes por provincia 2012-2021 (Porcentaje)

tabla1=prop.table(table(data$Provincia,data$MM_total,exclude = c(0)))*100
tabla1
##                       
##                                1
##   BAGUA                18.691589
##   BONGARA               4.672897
##   CHACHAPOYAS           6.542056
##   CONDORCANQUI         37.383178
##   LUYA                  4.672897
##   RODRIGUEZ DE MENDOZA  7.476636
##   UTCUBAMBA            20.560748

Gráfico: Total de muertes maternas en Amazonas por año

#Opción 1
library(plotly)
## Loading required package: ggplot2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:rio':
## 
##     export
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
grafico1=plot_ly(data1, x=data1$Año, y=data1$MM_total, type = 'bar',text= data1$MM_total ,textposition = 'auto')
grafico1 <- grafico1 %>% layout(xaxis = list(title = ""), yaxis = list(title = ""))
grafico1
#Opción 2
library(ggplot2)
grafico2=ggplot(data=data1, aes(x=Año, y=MM_total)) + geom_col(fill="steelblue") + geom_text(aes(label = MM_total), vjust = - 0.5, size = 3.5) + theme_minimal() + labs (y = NULL, x = NULL) + scale_y_continuous(limit = c(0,20)) 
grafico2

Gráfico: Total de muertes maternas por tipo en Amazonas por año

grafico3=plot_ly(data1, x=data1$Año, y=data1$MM_directa, name="Muerte materna directa", type = 'bar',text= data1$MM_directa ,textposition = 'auto')
grafico3=grafico3 %>% add_trace(y = ~MM_indirecta, name = 'Muerte materna indirecta', text= data1$MM_indirecta ,textposition = 'auto')
grafico3=grafico3 %>% layout(yaxis = list(title = ''), barmode = 'stack',legend = list(x = 0, y = 1, bgcolor = 'rgba(255, 255, 255, 0)', bordercolor = 'rgba(255, 255, 255, 0)'))
grafico3

Tabla: Total de muertes maternas por semana en Amazonas por año

tabla2=table(data$Semana,data$Año)
library(RColorBrewer)
library(latticeExtra)
## Loading required package: lattice
## 
## Attaching package: 'latticeExtra'
## The following object is masked from 'package:ggplot2':
## 
##     layer
mitema <- modifyList(custom.theme(region = brewer.pal(9, 'Reds')),
                     list(
                       strip.background = list(col = 'gray'),
                       panel.background = list(col = 'gray')))
grafico4=levelplot(tabla2, xlab = 'Semana epidemiológica', ylab = "",par.settings = mitema) 
grafico4

Gráfico: Total de muertes maternas por provincia en Amazonas por año

library(ggplot2)
library(viridis)
## Loading required package: viridisLite
library(hrbrthemes)
## NOTE: Either Arial Narrow or Roboto Condensed fonts are required to use these themes.
##       Please use hrbrthemes::import_roboto_condensed() to install Roboto Condensed and
##       if Arial Narrow is not on your system, please see https://bit.ly/arialnarrow
grafico5=ggplot(data, aes(fill=Provincia, y=MM_total, x=Año)) + geom_bar(position="stack", stat="identity") + scale_fill_viridis(discrete = T, option = "E") + facet_wrap(~Provincia,ncol=2) + theme_minimal() + theme(legend.position="none") + labs (x= NULL, y = NULL) + scale_fill_brewer(palette = "Dark2")
## Scale for 'fill' is already present. Adding another scale for 'fill', which
## will replace the existing scale.
grafico5

Análisis descriptivo de Condorcanqui

Subset de Condorcanqui

data2= data[data$Provincia=="CONDORCANQUI",]
data3=aggregate(cbind(MM_directa, MM_indirecta, MM_total) ~ Año, data = data2, sum)

Gráfico: Total de muertes maternas en Condorcanqui por año

#Opción 1
grafico6=plot_ly(data3, x=data3$Año, y=data3$MM_total, type = 'bar',text= data3$MM_total ,textposition = 'auto')
grafico6 <- grafico6 %>% layout(xaxis = list(title = ""), yaxis = list(title = ""))
grafico6
#Opción 2
grafico7=ggplot(data=data3, aes(x=Año, y=MM_total)) + geom_col(fill="steelblue") + geom_text(aes(label = MM_total), vjust = - 0.5, size = 3.5) + theme_minimal() + labs (y = NULL, x = NULL) + scale_y_continuous(limit = c(0,10)) 
grafico7

Gráfico: Total de muertes maternas por tipo en Condorcanqui por año

grafico8=plot_ly(data3, x=data3$Año, y=data3$MM_directa, name="Muerte materna directa", type = 'bar',text= data3$MM_directa ,textposition = 'auto')
grafico8=grafico8 %>% add_trace(y = ~MM_indirecta, name = 'Muerte materna indirecta', text= data3$MM_indirecta ,textposition = 'auto')
grafico8=grafico8 %>% layout(yaxis = list(title = ''), barmode = 'stack',legend = list(x = 0, y = 1, bgcolor = 'rgba(255, 255, 255, 0)', bordercolor = 'rgba(255, 255, 255, 0)'))
grafico8

Tabla: Total de muertes maternas por semana en Condorcanqui por año

tabla3=table(data2$Semana,data2$Año)
library(RColorBrewer)
grafico9=levelplot(tabla3,xlab = 'Semana epidemiológica', ylab = "",par.settings = mitema) 
grafico9

Gráfico: Total de muertes maternas por distrito en Condorcanqui por año

grafico10=ggplot(data2, aes(fill=Distritos, y=MM_total, x=Año)) + geom_bar(position="stack", stat="identity") + scale_fill_viridis(discrete = T, option = "E") + facet_wrap(~Distritos,ncol=2) + theme_minimal() + theme(legend.position="none") + labs (x= NULL, y = NULL) 
grafico10