Skip to content

Instantly share code, notes, and snippets.

@diegovalle diegovalle/pm25_o3.R
Last active May 15, 2019

Embed
What would you like to do?
library(lubridate)
library(aire.zmvm)
library(ggplot2)
library(dplyr)
library(hrbrthemes)
get_latest_imeca()
df <- get_zone_imeca("HORARIOS", "TC", "TZ", "2019-05-01", "2019-05-14")
df$datetime <- ymd_h(paste0(df$date, " ", df$hour))
df <- df %>%
filter(pollutant %in% c("O3", "PM25")) %>%
group_by(datetime, pollutant) %>%
summarise(max = max(value))
ggplot(df, aes(datetime, max)) +
geom_line() +
facet_wrap(~pollutant) +
ylab("IMECA") +
geom_hline(yintercept = 151, color = "#fc9272") +
annotate("text", y = 160, x = as.POSIXct("2019-05-10"), label = "Contingencia") +
xlab("fecha y hora") +
labs(title = expression(paste("Máximos horarios de ", O[3], " y ", PM[2.5]))) +
theme_ft_rc()
df <- get_zone_imeca("MAXIMOS", "PM25", "TZ", "2009-01-01", "2019-05-14")
df <- df %>%
group_by(date) %>%
summarise(max = max(value))
ggplot(df, aes(date, max)) +
geom_line(size = .3) +
ylab("IMECA") +
geom_smooth() +
geom_hline(yintercept = 151, color = "#fc9272") +
annotate("text", y = 155, x = as.Date("2018-05-10"), label = "151 puntos", color = "#fc9272") +
xlab("fecha") +
labs(title = expression(paste("Máximos diarios de ", PM[2.5], " (2009-2019)"))) +
theme_ft_rc()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.