Muestra Covid

El análisis de datos sobre COVID-19 permite comprender su impacto en diferentes poblaciones. En este informe, exploramos la edad promedio de los casos reportados según el departamento y el sexo. Usaremos gráficos interactivos para identificar tendencias clave y facilitar la interpretación de los resultados.

summary(Covid)
##    Divipola         Departamento        Municipio              Edad      
##  Length:1500        Length:1500        Length:1500        Min.   : 1.00  
##  Class :character   Class :character   Class :character   1st Qu.:27.00  
##  Mode  :character   Mode  :character   Mode  :character   Median :37.00  
##                                                           Mean   :39.54  
##                                                           3rd Qu.:52.00  
##                                                           Max.   :96.00  
##      Sexo              Fecha          
##  Length:1500        Length:1500       
##  Class :character   Class :character  
##  Mode  :character   Mode  :character  
##                                       
##                                       
## 
# Promedio, desviacion y mediana de edad por departamento
depart <- Covid %>%
  select(Edad, Departamento) %>%
  group_by(Departamento) %>%
  summarize(Prom_Edad = mean(Edad),
            sdEdad = sd(Edad),
            Med.Edad = median(Edad)) %>%
  arrange(-Prom_Edad)
depart
## # A tibble: 32 × 4
##    Departamento Prom_Edad sdEdad Med.Edad
##    <chr>            <dbl>  <dbl>    <dbl>
##  1 AMAZONAS          58.5   2.89     58.5
##  2 TOLIMA            45.1  19.6      49.5
##  3 CHOCO             44    28.5      39  
##  4 QUINDIO           43.8  17.0      43  
##  5 CALDAS            43.7  20.1      40  
##  6 RISARALDA         43.7  15.9      43  
##  7 NARIÑO           43.1  18.6      42  
##  8 CAUCA             41.9  16.3      37  
##  9 ATLANTICO         41.8  19.9      41  
## 10 BOLIVAR           41.5  13.4      39.5
## # ℹ 22 more rows
# Promedio, desviacion y mediana de edad por sexo
sex <- Covid %>%
  select(Edad, Sexo) %>%
  group_by(Sexo) %>%
  summarize(Prom_Edad = mean(Edad),
            sdEdad = sd(Edad),
            Med.Edad = median(Edad)) %>%
  arrange(-Prom_Edad)
sex
## # A tibble: 2 × 4
##   Sexo  Prom_Edad sdEdad Med.Edad
##   <chr>     <dbl>  <dbl>    <dbl>
## 1 F          41.1   17.4     39  
## 2 M          37.8   16.9     35.5
# Promedio, desviacion y mediana de edad por departamento y sexo
depart_sex <- Covid %>%
  select(Edad, Departamento, Sexo) %>%
  group_by(Departamento, Sexo) %>%
  summarize(Prom_Edad = mean(Edad),
            sdEdad = sd(Edad),
            Med.Edad = median(Edad)) %>%
  arrange(-Prom_Edad)
## `summarise()` has grouped output by 'Departamento'. You can override using the
## `.groups` argument.
depart_sex
## # A tibble: 60 × 5
## # Groups:   Departamento [32]
##    Departamento Sexo  Prom_Edad sdEdad Med.Edad
##    <chr>        <chr>     <dbl>  <dbl>    <dbl>
##  1 AMAZONAS     F          59.7   2.08     59  
##  2 AMAZONAS     M          55    NA        55  
##  3 QUINDIO      F          49.4  18.6      52  
##  4 CHOCO        M          49    41.0      49  
##  5 CALDAS       F          48.5  18.0      46  
##  6 TOLIMA       M          47.7  21.9      51.5
##  7 CORDOBA      F          47.5  15.5      49  
##  8 NARIÑO      F          46.4  19.6      49  
##  9 META         M          46.1  11.1      46.5
## 10 MAGDALENA    F          46    18.7      48  
## # ℹ 50 more rows

Visualización de Datos

Promedio de Edad por Departamento

grafico1 <- ggplot(depart, aes(x = reorder(Departamento, Prom_Edad), y = Prom_Edad)) +
  geom_point() +
  theme_minimal() +
  labs(title = "Promedio de Edad por Departamento",
       x = "Departamento", y = "Edad")

ggplotly(grafico1)

Promedio de Edad por Sexo

grafico2 <- ggplot(sex, aes(x = Sexo, y = Prom_Edad)) +
  geom_bar(stat = "identity", fill = "skyblue", color = "black") +
  geom_text(aes(label = round(Prom_Edad, 1), vjust = -0.5)) +
  labs(x = "Sexo", y = "Edad",
       title = "Promedio de Edad por Sexo")

ggplotly(grafico2)

Promedio de Edad por Departamento y Sexo

grafico3 <- ggplot(depart_sex, aes(x = Departamento, y = Prom_Edad, fill = Sexo)) +
  geom_bar(stat = "identity", position = "dodge") +
  labs(x = "Departamento", y = "Edad",
       title = "Promedio de Edad por Departamento y Sexo") +
  theme_minimal()

ggplotly(grafico3)