pacman::p_load(rio, dplyr, lubridate, readxl, stringr, table1) 
suicidio <- read_excel("C:/Users/User/Downloads/YDRAY-2024_356_Reporte.xlsx")  
## Warning: Expecting numeric in BT1133 / R1133C72: got 'INSTITUCIONA'
require(table1)
table1(~sexo_+edad_+estrato_+estado_civ, data=suicidio)
Overall
(N=1325)
sexo_
F 858 (64.8%)
M 467 (35.2%)
edad_
Mean (SD) 25.8 (12.6)
Median [Min, Max] 22.0 [8.00, 90.0]
estrato_
Mean (SD) 2.19 (0.997)
Median [Min, Max] 2.00 [1.00, 6.00]
Missing 57 (4.3%)
estado_civ
Mean (SD) 1.51 (0.940)
Median [Min, Max] 1.00 [1.00, 5.00]
# voy a ajustar la variable estrato y la variable estado civil por q las esta tomando como número

suicidio$estrato_=as.factor(suicidio$estrato_)

#ajusto la variable estado civil

suicidio$estado_civ=factor(suicidio$estado_civ, levels = c(1, 2, 3, 4, 5), labels = c("soltero", "casado", "unión libre", "viudo", "divorciado"))

#Ajustar escolaridad
suicidio$escolarid2 = factor(suicidio$escolarid, levels = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14), labels = c("preescolar","jardin", "primaria", "secundaria", "técnica", "tecnólogo", "profesional","profesional2", "especialista", "magister", "PhD", "ninguno", "otro", "sin información"))

require(table1)
table1(~sexo_+edad_+estrato_+estado_civ+escolarid2, data=suicidio)
Overall
(N=1325)
sexo_
F 858 (64.8%)
M 467 (35.2%)
edad_
Mean (SD) 25.8 (12.6)
Median [Min, Max] 22.0 [8.00, 90.0]
estrato_
1 282 (21.3%)
2 636 (48.0%)
3 240 (18.1%)
4 61 (4.6%)
5 35 (2.6%)
6 14 (1.1%)
Missing 57 (4.3%)
estado_civ
soltero 978 (73.8%)
casado 84 (6.3%)
unión libre 224 (16.9%)
viudo 13 (1.0%)
divorciado 26 (2.0%)
escolarid2
preescolar 14 (1.1%)
jardin 278 (21.0%)
primaria 653 (49.3%)
secundaria 0 (0%)
técnica 70 (5.3%)
tecnólogo 0 (0%)
profesional 64 (4.8%)
profesional2 38 (2.9%)
especialista 85 (6.4%)
magister 6 (0.5%)
PhD 2 (0.2%)
ninguno 2 (0.2%)
otro 8 (0.6%)
sin información 105 (7.9%)

##A continuación se realizará una exploración de los casos reportados diariamente

require (ggplot2)
## Cargando paquete requerido: ggplot2
suicidio$fecha= as.Date(suicidio$fec_not, format = "%d/%m/%y")
fig1= ggplot(suicidio, aes(x=fecha))+geom_bar(fill="blue")+ theme_classic()
require(plotly)
## Cargando paquete requerido: plotly
## 
## Adjuntando el paquete: '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
ggplotly(fig1)