library(tidyverse)
library(ggplot2)
library(countrycode)
library(rnoaa)
library(cubble)
library(weatherdata)
worldwide <- ghcnd_stations() %>%
filter((wmo_id)!= "") %>%
filter(first_year <= 2016, last_year >= 2020) %>%
filter_major_three() %>%
mutate(country = str_sub(id, 1, 2)) %>%
rename(country_abb = country)
austria_raw <- worldwide %>% filter(country_abb == "AU") %>%
mutate(ts = list(meteo_pull_monitors(monitors = id,
var = c("PRCP", "TMAX", "TMIN"),
date_min = "2016-01-01",
date_max = "2020-12-31"))) %>%
as_cubble(index = date, key = id, coords = c(longitude, latitude))
# only 4 stations has a reasonable amount of missing for tmax that allows
# to process
good_id <- austria_raw %>%
add_missing_prct(prcp:tmin) %>%
select(id, contains("missing")) %>%
filter(tmax_missing < 0.1) %>%
pull(id)
austria <- austria_raw %>%
filter(id %in% good_id) %>%
mutate(ts = list(ts %>% select(-prcp, -tmin)))
usethis::use_data(austria, overwrite = TRUE)
################################################################
austria %>%
face_temporal() %>%
mutate(yday = lubridate::yday(date),
year = as.factor(lubridate::year(date)),
wk = lubridate::week(date)) %>%
group_by(wk, year) %>%
summarise(tmax = mean(tmax, na.rm = TRUE)) %>%
ggplot(aes(x = wk , y = tmax, color = year)) +
geom_line() +
facet_wrap(vars(id))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.