if (FALSE) {
start <- as.POSIXlt("2018-06-19T00", tz = "UTC")
end <- lubridate::floor_date(Sys.time()- lubridate::days(2), unit = "day")
attr(end, "tzone") <- "UTC"
offset <- 2000
api_key <- Sys.getenv("eia_key")
api_path <- "electricity/rto/region-sub-ba-data/data/"
facets = list(parent = "NYIS",
subba = "ZONA")
df <- eia_backfill(start = start,
end = end,
offset = offset,
api_key = api_key,
api_path = api_path,
facets = facets)
at_y <- pretty(df$value)[c(2, 4, 6)]
at_x <- seq.POSIXt(from = start,
to = end,
by = "2 years")
plot(df$time, df$value,
col = "#1f77b4",
type = "l",
frame.plot = FALSE,
axes = FALSE,
panel.first = abline(h = at_y, col = "grey80"),
main = "NY Independent System Operator (West) - Hourly Generation of Electricity",
xlab = "Source: https://www.eia.gov/",
ylab = "MegaWatt/Hours")
mtext(side =1, text = format(at_x, format = "%Y"), at = at_x,
col = "grey20", line = 1, cex = 0.8)
mtext(side =2, text = format(at_y, scientific = FALSE), at = at_y,
col = "grey20", line = 1, cex = 0.8)
}
Run the code above in your browser using DataLab