Importación de dataset
library(readr)
## Warning: package 'readr' was built under R version 4.3.3
data <- read_csv("E:/data_modificado.xls")
## Rows: 70668 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): id, particula
## dbl (2): pm10, pm25
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
data_first_100 <- head(data, 100)
View(data_first_100)
Librería ggplot2
library(ggplot2)
Gráficas de dispersión
ggplot(data_first_100, aes(x = pm10, y = pm25)) +
geom_point(color = 'blue', alpha = 0.6) +
labs(title = "Relación entre PM10 y PM25",
x = "PM10",
y = "PM25") +
theme_minimal()

Histogramas
ggplot(data_first_100, aes(x = pm10)) +
geom_histogram(binwidth = 10, fill = 'blue', alpha = 0.6) +
labs(title = "Histograma de PM10",
x = "PM10",
y = "Frecuencia") +
theme_minimal()

Gráfico de barras combinado
ggplot(data_first_100, aes(x = pm10)) +
geom_histogram(binwidth = 10, fill = 'blue', alpha = 0.6) +
labs(title = "Histograma de PM10",
x = "PM10",
y = "Frecuencia") +
theme_minimal()

ggplot(data_first_100, aes(x = pm25)) +
geom_histogram(binwidth = 5, fill = 'green', alpha = 0.6) +
labs(title = "Histograma de PM25",
x = "PM25",
y = "Frecuencia") +
theme_minimal()

ggplot(data_first_100) +
geom_histogram(aes(x = pm10, fill = "PM10"), binwidth = 10, alpha = 0.6, position = 'identity') +
geom_histogram(aes(x = pm25, fill = "PM25"), binwidth = 5, alpha = 0.6, position = 'identity') +
labs(title = "Histogramas de PM10 y PM25",
x = "Concentración",
y = "Frecuencia",
fill = "Medida de Partícula") +
theme_minimal()

Densidad de Kernel
ggplot(data_first_100) +
geom_density(aes(x = pm10, fill = "PM10"), alpha = 0.6) +
geom_density(aes(x = pm25, fill = "PM25"), alpha = 0.6) +
labs(title = "Curvas de Densidad de PM10 y PM25",
x = "Concentración",
y = "Densidad",
fill = "Medida de Partícula") +
theme_minimal()
