UNIVERSIDAD CENTRAL DEL ECUADOR

PROYECTO:ESTUDIO ESTADÍSTICO DE LA CALIDAD DE AIRE EN LA INDIA

FECHA: 22/11/2025

```{r, echo=TRUE,warning=FALSE,message=FALSE}

#Estadística Descriptiva #Ariana Viteri #19/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

#StationName StationName<- datos\(StationName #Tabla de distribución de frecuencia TDF_StationName<- data.frame(table(StationName)) ni <- TDF_StationName\)Freq hi <- round((ni / sum(ni)) *100,2) StationName <- TDF_StationName$StationName TDF_StationName <- data.frame(StationName,ni,hi) Summary <- data.frame(StationName = “TOTAL”, ni=sum(ni), hi = 100)

TDF_StationName_suma <- rbind(TDF_StationName,Summary)

colnames(TDF_StationName_suma) <- c(“Nombre_Oficial”, “ni”, “hi(%)”)

TABLA

TDF_StationName_suma %>% gt() %>% tab_header( title = md(“Tabla Nro. 3”), subtitle = md(“Tabla de distribución de frecuencias del Nombre oficial de la estación de monitoreo”) ) %>% 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 No.1 #Distribuccion de StationName #GDF 1

TDF_StationName\(StationName <- iconv(TDF_StationName\)StationName, from = “latin1”, to = “UTF-8”, sub = ““) barplot( height = TDF_StationName\(ni, names.arg = TDF_StationName\)StationName, main =”Gráfica No. 1.1: Distribución de StationName”, xlab = ““, ylab =”Cantidad”, col = heat.colors(length(TDF_StationName$ni)), las = 2, cex.names = 0.7 ) mtext(“StationName”, side = 1, line = 4, cex = 1)

DIAGRAMA DE BARRAS (GLOBAL)

colores <- c(“yellow”, “orange”, “red”)

barplot(TDF_StationName$ni, main = “Gráfica 1.2: Distribución de StationName”, xlab = ““, ylab =”Cantidad”,

    col = colores,
    names.arg = TDF_StationName$StationName,
    ylim = c(0, 22500),
    las = 2,
    cex.names = 0.7

) mtext(“StationName”, side = 1, line = 4, cex = 1)

DIAGRAMA DE BARRAS (Porcentaje)

barplot(TDF_StationName\(hi, main = "Grafica No 1.3: Distribución de Zona (porcentaje) de StationName", xlab = "", ylab = "Porcentaje (%)", col = colores, names.arg = TDF_StationName\)StationName, ylim = c(0, 30), las = 2, cex.names = 0.7 ) mtext(“AQI_Bucket”, side = 1, line = 4, cex = 1)

DIAGRAMA DE BARRAS (Porcentaje)

colores <- c(“yellow”, “orange”)

“barplot”(TDF_StationName\(hi, main = "Grafica N°1.4: Distribución de StationName (Porcentaje)", xlab = "", ylab = "Porcentaje (%)", col = colores, names.arg = TDF_StationName\)StationName, ylim = c(0, 100), las = 2, cex.names = 0.7 ) mtext(“StationName”, side = 1, line = 2, cex = 1)

#creacion de agrupacion tabla_StationName <- unique(datos[, c(“City”, “Zona”)]) colnames(tabla_StationName) <- c(“Ciudades”, “Zona”) TDF_sin_total <- TDF_StationName[TDF_StationName\(StationName != "TOTAL", ] TDF_final <- merge(TDF_sin_total, tabla_StationName, all.x = TRUE) # Crear total fila_total <- data.frame( StationName = "TOTAL", ni = sum(TDF_final\)ni), hi(%) = 100, Zona = NA, stringsAsFactors = FALSE )

Grupo<-table(TDF_final$StationName) hi_grupo<-Grupo/sum(Grupo) hi_grupo<-hi_grupo*100 TablaAgrupada<-aggregate(cbind(ni, hi(%)) ~ StationName, data = TDF_final, sum)

#Diagrama Circular library(RColorBrewer) n <- length(TDF_final$StationName) colores <- brewer.pal(min(n, 12), “Set3”) color <- adjustcolor(colores, alpha.f = 0.9) etiqueta<-paste(hi_red,“%”)

pie(hi_red, labels = etiqueta, radius = 1, col=color, main=“Gráfica No.5: Porcentaje de Ciudades en el Estudio de Calidad del aire en la India”)

legend(“bottomright”,legend=names(Grupo), title = “Leyenda”, fill=color)