FECHA: 21/11/2025
#Estadística Descriptiva
#Ariana Viteri
#20/11/2025
library(gt)
library(dplyr)
#Cargar los datos
datos<-read.csv("~/ariana tercer semestre/Estadistica/city_day.csv",header = TRUE,dec = ".",sep = ",")
#Tablas Cualitativas Nominales
#AQI_Bucket
AQI_Bucket <- datos$AQI_Bucket
#Tabla de distribución de frecuencia
TDF_AQI_Bucket <- data.frame(table(AQI_Bucket ))
ni <- TDF_AQI_Bucket$Freq
hi <- round((ni / sum(ni)) *100,2)
AQI_Bucket <- TDF_AQI_Bucket$AQI_Bucket
TDF_AQI_Bucket <- data.frame(AQI_Bucket,ni,hi)
Summary <- data.frame(AQI_Bucket = "TOTAL", ni=sum(ni), hi = 100)
TDF_AQI_Bucket_suma <- rbind(TDF_AQI_Bucket,Summary)
colnames(TDF_AQI_Bucket_suma) <- c("AQI_Nivel", "ni", "hi(%)")
TDF_AQI_Bucket_suma[TDF_AQI_Bucket_suma == ""] <- NA
TDF_AQI_Bucket_suma[TDF_AQI_Bucket_suma == ""] <- "NA"
# TABLA
TDF_AQI_Bucket_suma %>%
gt() %>%
fmt_missing(
columns = everything(),
missing_text = "NA"
)%>%
tab_header(
title = md("Tabla Nro. 5"),
subtitle = md("Tabla de distribución de frecuencias del nivel de contaminación")
) %>%
tab_source_note(
source_note = md("Fuente: Datos procesados por el autor a partir de archivo city.day.csv ")
) %>%
tab_style(
style = cell_borders(
sides = "left",
color = "black",
weight = px(2),
style = "solid"
),
locations = cells_body()
) %>%
tab_style(
style = cell_borders(
sides = "right",
color = "black",
weight = px(2),
style = "solid"
),
locations = cells_body()
) %>%
tab_style(
style = cell_borders(
sides = "left",
color = "black",
weight = px(2),
style = "solid"
),
locations = cells_column_labels()
) %>%
tab_style(
style = cell_borders(
sides = "right",
color = "black",
weight = px(2),
style = "solid"
),
locations = cells_column_labels()
)%>%
tab_options(
table.border.top.color = "black",
table.border.bottom.color = "black",
table.border.top.style = "solid",
table.border.bottom.style = "solid",
column_labels.border.top.color = "black",
column_labels.border.bottom.color = "black",
column_labels.border.bottom.width = px(2),
row.striping.include_table_body = TRUE,
heading.border.bottom.color = "black",
heading.border.bottom.width = px(2),
table_body.hlines.color = "gray",
table_body.border.bottom.color = "black"
)
| Tabla Nro. 5 |
| Tabla de distribución de frecuencias del nivel de contaminación |
| AQI_Nivel |
ni |
hi(%) |
| - |
4681 |
15.85 |
| Good |
1341 |
4.54 |
| Moderate |
8829 |
29.90 |
| Poor |
2781 |
9.42 |
| Satisfactory |
8224 |
27.85 |
| Severe |
1338 |
4.53 |
| Very Poor |
2337 |
7.91 |
| TOTAL |
29531 |
100.00 |
| Fuente: Datos procesados por el autor a partir de archivo city.day.csv |