knitr::opts_chunk$set( collapse = T, comment = NA, warning=F, message=F, eval=T, echo=T, error=F, comment = "#>", fig.path="../figures/" )
# Load bdc & ggplot2 package library(bdc); library(dplyr); library(ggplot2); library(patchwork) # Load climate data from BDC package data(dwd_annual_ts_bav, package="bdc") head(dwd_annual_ts_bav) # Cold-temperature related variables p1 <- dwd_annual_ts_bav %>% filter(Jahr >= 1980) %>% ggplot(aes(x=Jahr)) + geom_line(aes(y=air_temperature_mean)) p2 <- dwd_annual_ts_bav %>% filter(Jahr >= 1980) %>% ggplot(aes(x=Jahr)) + geom_bar(aes(y=frost_days), stat="identity") p3 <- dwd_annual_ts_bav %>% filter(Jahr >= 1980) %>% ggplot(aes(x=Jahr)) + geom_bar(aes(y=ice_days), stat="identity") p1 + p2 + p3 + plot_layout(ncol=1) & theme_bw() & scale_x_continuous(limits=c(1979.25,2020.75), expand=c(0,0), breaks=c(1980, 1990,2000,2010,2020)) # Warm-temperature related variables p4 <- dwd_annual_ts_bav %>% filter(Jahr >= 1980) %>% ggplot(aes(x=Jahr)) + geom_bar(aes(y=hot_days), stat="identity") p5 <- dwd_annual_ts_bav %>% filter(Jahr >= 1980) %>% ggplot(aes(x=Jahr)) + geom_line(aes(y=tropical_nights_tminGE20)) p6 <- dwd_annual_ts_bav %>% filter(Jahr >= 1980) %>% ggplot() + geom_bar(aes(x=Jahr, y=summer_days), stat="identity") p7 <- dwd_annual_ts_bav %>% filter(Jahr >= 1980) %>% ggplot() + geom_line(aes(x=Jahr, y=sunshine_duration)) p1 + p4 + p5 + p6 + p7 + plot_layout(ncol=1) & theme_bw() & scale_x_continuous(limits=c(1979.25,2020.75), expand=c(0,0), breaks=c(1980, 1990,2000,2010,2020)) # Precipitation related variables p8 <- dwd_annual_ts_bav %>% filter(Jahr >= 1980) %>% ggplot() + geom_line(aes(x=Jahr, y=precipGE10mm_days)) p9 <- dwd_annual_ts_bav %>% filter(Jahr >= 1980) %>% ggplot() + geom_line(aes(x=Jahr, y=precipGE20mm_days)) p10 <- dwd_annual_ts_bav %>% filter(Jahr >= 1980) %>% ggplot() + geom_line(aes(x=Jahr, y=precipitation)) p8 + p9 + p10 + plot_layout(ncol=1) & theme_bw() & scale_x_continuous(limits=c(1979.25,2020.75), expand=c(0,0), breaks=c(1980, 1990,2000,2010,2020))
# GGally, to assess the distribution and correlation of variables library(GGally) # Check correlations (as scatterplots), distribution and print correlation coefficient ggpairs(dwd_annual_ts_bav %>% filter(Jahr >= 1980) %>% select(-Jahr)) # Check correlation between variables #cor(dwd_annual_ts_bav %>% filter(Jahr >= 1980) %>% select(-Jahr)) # Nice visualization of correlations ggcorr(dwd_annual_ts_bav %>% filter(Jahr >= 1980) %>% select(-Jahr), nbreaks = 9,method = c("everything", "pearson"), label=T) rm(list=ls()); invisible(gc())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.