library(data.table)
library(ggplot2)
library(showtext)
library(sf)
library(lubridate)
library(magrittr)
library(Cairo)
library(egg)
library(stringr)
library(tidync)
china_map <- st_read('data-raw/shp/chn_admbnda_adm1_ocha_2020.shp')
font_add('Poppins-SemiBold', 'data-raw/Poppins-SemiBold.ttf')
font_add('Ubuntu-Regular', 'data-raw/Ubuntu-Regular.ttf')
font_add('Ubuntu-Medium', 'data-raw/Ubuntu-Medium.ttf')
showtext_auto(enable = TRUE)
dir <- dir('OUTPUT/clusterId', recursive=TRUE, full.names = TRUE)
for (i in dir){
dt <- tidync(i) %>% hyper_tibble() %>% setDT()
dt[, date := as_date(time)]
for (j in unique(year(dt$date))) {
id <- str_sub(i, -4, -4)
add <- str_sub(i, 17, -4)
HW_plot(dt,
interval = j,
title = paste0('Heatwave ', id),
file = paste0('OUTPUT/plot', add, '_', j, '.pdf'))
}
rm(dt)
gc()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.