Created
January 30, 2021 01:12
-
-
Save juanchiem/3c07fe3a10875b590bcc2850a52f3a44 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
#temp | |
dates <- seq.Date(lubridate::dmy("1-6-2020"), lubridate::dmy("15-12-2020"), by = "1 day") | |
temp <- metR::GetSMNData(dates, type = "daily", bar = TRUE) | |
# temp %>% distinct(station) %>% pull() | |
temp %>% | |
filter(station == "TANDIL AERO") %>% | |
mutate(date = as.Date(date)) %>% | |
ggplot()+ | |
aes(x=date, y = tmin)+ | |
geom_line(aes(col = "mín"))+ | |
geom_line(aes(y = tmax, col= "máx"))+ | |
theme_bw()+ | |
labs(title = "Temperatura", x = "", y = "°C")+ | |
# scale_x_date(date_labels = "%B") | |
scale_color_manual(name = NULL,values = c( | |
'mín' = 'steelblue', | |
'máx' = 'red3'))+ | |
scale_x_date(breaks="month", labels=scales::date_format("%b"))+ | |
theme(legend.justification = c(0, 1), legend.position = c(0.01, 0.98)) -> temp_p | |
temp_p | |
#mm | |
coop_dir = tempfile(fileext = ".xls") | |
dataURL <- "http://coopnecochea.com/web/download/lluvias/Lluvias-2020.xls" | |
download.file(dataURL, destfile=coop_dir) | |
total_2020 <- tibble(mes = coop_dir %>% readxl::excel_sheets()) %>% | |
mutate(data = map(mes, ~readxl::read_excel(coop_dir, sheet = .x) %>% | |
mutate_all(as.character))) %>% | |
slice(n()) %>% | |
unnest(cols = c(data)) %>% | |
drop_na(Lugar) | |
total_2020 %>% | |
select(-TOTAL,-mes) %>% | |
pivot_longer(cols = c(`ENE`:`DIC`), | |
names_to = "mes", | |
values_to = "mm") %>% | |
filter(Lugar == "Balcarce", | |
mes %in% c("JUN", "JUL", "AGO", "SEP", "OCT", "NOV", "DIC")) %>% | |
mutate(mes = tolower(mes), | |
mes = as.factor(mes), | |
mes = fct_relevel(mes, "jun", "jul", "ago", "sep", "oct", "nov", "dic"), | |
mm = as.numeric(mm)) %>% | |
ggplot()+ | |
aes(x = mes, y=mm)+ | |
geom_col(fill = "steelblue")+ | |
geom_text(aes(label = mm, x = mes, y = mm, vjust= 1.2), size =3, col = "white")+ | |
theme_bw()+ | |
labs(title = "Precipitaciones acumuladas mensuales", x = "")->mm_p | |
library(patchwork) | |
(temp_p + mm_p) | |
ggsave(last_plot(), file = "temp_mm.png", width = 8, height = 4) |
Author
juanchiem
commented
Jan 30, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment