---
title: "Climate Change Indicators"
#author: "Wanda Bodnar"
#date: "20/01/2022"
output:
flexdashboard::flex_dashboard:
source_code: embed
theme:
version: 4
primary: "black"
navbar-bg: "black"
orientation: columns
vertical_layout: fill
---
```{r setup, include=FALSE}
library(flexdashboard)
```
Temperature
=======================================================================
Column {.tabset}
-------------------------------------
### Climate reconstruction of the Common Era { .chart-1 }
```{r}
### PAGES2k Global 2,000 Year Multiproxy Database: https://www.ncei.noaa.gov/access/paleo-search/study/21171
### Berkeley Earth: http://berkeleyearth.lbl.gov/auto/Global/Land_and_Ocean_summary.txt
library(ggplot2)
library(RColorBrewer)
library(plotly)
library(tidyr)
library(formattable)
c <- read.csv("c.csv")
c$Anomaly <- formattable(c$Anomaly, format = "f", digits = 2)
col_strip <- brewer.pal(11, "RdBu")
cc <- ggplot() +
geom_bar(data = c, aes(x = Year, y = Anomaly, fill = Anomaly, text = Anomaly), stat = "identity") +
geom_hline(yintercept = 0, linetype = "dotted",
color = "white", size = .5) +
geom_hline(yintercept = 1, linetype = "dashed",
color = "white", size = .3) +
scale_fill_gradientn(colors = rev(col_strip)) +
scale_x_continuous(breaks = c(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1712, 1800, 2021)) +
scale_y_continuous(breaks = c(0, 1)) +
annotate("text", x = 1712, y = 0.25, colour = "white", label = "1712: \nInvention of \nsteam engine") +
annotate("segment", xend = 1712, yend = 0.05, x = 1712, y = 0.15, colour = "white",
arrow = arrow(length = unit(2, "mm"), type = "closed")) +
ylab("Anomaly °C") +
theme(plot.background = element_rect(fill = "black"),
panel.background = element_rect(fill = "black"),
legend.background = element_rect(fill = "black"),
legend.text = element_text(colour = "white", size = 10),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_text(colour = "white", size = 10),
axis.text = element_text(colour = "white", size = 10),
axis.line = element_line(colour = "white"),
plot.title = element_text(colour = "white", hjust = 0.5),
plot.subtitle = element_text(colour = "white", hjust = 0.5),
plot.caption = element_text(colour = "white"))
ggplotly(cc, tooltip = "text")
```
### Climate stripes { .chart-2 }
```{r}
### Berkeley Earth: http://berkeleyearth.lbl.gov/auto/Global/Land_and_Ocean_summary.txt
### Warming stripes: @ Ed Hawkins https://showyourstripes.info/s/globe
library(ggplot2)
library(RColorBrewer)
library(plotly)
library(tidyr)
library(formattable)
combined <- read.csv("berkeley.csv")
combined$Anomaly <- formattable(combined$Anomaly, format = "f", digits = 2)
theme_strip <- theme_minimal()+
theme(axis.text.y = element_blank(),
axis.line.y = element_blank(),
panel.grid.major = element_blank(),
axis.text.x = element_text(vjust = 3, colour = "white", size = 10),
panel.grid.minor = element_blank(),
axis.title = element_blank(),
plot.background = element_rect(fill = "black"),
panel.background = element_rect(fill = "black"),
legend.background = element_rect(fill = "black"),
legend.text = element_text(colour = "white", size = 10))
col_strip <- brewer.pal(11, "RdBu")
c <- ggplot(combined, aes(x = Year, y = 1, fill = Anomaly)) +
geom_tile(aes(text = Anomaly)) +
scale_y_continuous(expand = c(0, 0)) +
scale_x_continuous(breaks = c(1850, 1860, 1870, 1880, 1890, 1900, 1910, 1920,
1930, 1940, 1950, 1960, 1970, 1980, 1990,
2000, 2010, 2021)) +
scale_fill_gradientn(name = "Anomaly °C", colors = rev(col_strip)) +
guides(fill = guide_colorbar(barwidth = 0.5)) +
theme_strip
ggplotly(c, tooltip = "text")
```
### Climate prediction (reaching 1.5°C and 2°C at the current pace) { .chart-3 }
```{r}
### Berkeley Earth: http://berkeleyearth.lbl.gov/auto/Global/Land_and_Ocean_summary.txt
### Climate prediction: https://twitter.com/jrockstrom/status/1482616870394023936
library(ggplot2)
library(RColorBrewer)
library(plotly)
library(tidyr)
library(formattable)
combined <- read.csv("berkeley.csv")
combined$Anomaly <- formattable(combined$Anomaly, format = "f", digits = 2)
col_strip <- brewer.pal(11, "RdBu")
forecast <- read.csv("berkeley_f.csv")
forecast$Anomaly <- formattable(forecast$Anomaly, format = "f", digits = 2)
annotation <- data.frame(
x = c(2033, 2060),
y = c(1.6, 2.1),
label = c("1.5°C", "2°C"))
f <- ggplot() +
geom_bar(data = combined, aes(x = Year, y = Anomaly, fill = Anomaly, text = Anomaly), stat = "identity") +
geom_bar(data = forecast, show.legend = FALSE, aes(x = Year, y = Anomaly, text = Anomaly), fill = c("#520018", "#3d0012"), colour = "black", stat = "identity") +
geom_hline(yintercept = 0, linetype = "dotted",
color = "white", size = .5) +
geom_hline(yintercept = 1, linetype = "dashed",
color = "white", size = .3) +
geom_hline(yintercept = 1.5, linetype = "dashed",
color = "white", size = .3) +
geom_hline(yintercept = 2, linetype = "dashed",
color = "white", size = .3) +
scale_fill_gradientn(colors = rev(col_strip)) +
scale_x_continuous(breaks = c(1850, 1860, 1870, 1880, 1890, 1900, 1910, 1920,
1930, 1940, 1950, 1960, 1970, 1980, 1990,
2000, 2010, 2021, 2033, 2060)) +
scale_y_continuous(breaks = c(0, 1, 1.5, 2)) +
geom_text(data = annotation, aes(x = x, y = y, label = label),
color = "white",
size = 4, fontface = "bold" ) +
annotate("text", x = 1995, y = -0.3, colour = "white", label = "COP1") +
annotate("segment", x = c(1995), y = -0.05, xend = c(1995), yend = c(-0.2), colour = "white",
arrow = arrow(length = unit(2, "mm"), type = "closed")) +
annotate("text", x = 2021, y = -0.3, colour = "white", label = "COP26") +
annotate("segment", x = c(2021), y = -0.05, xend = c(2021), yend = c(-0.2), colour = "white",
arrow = arrow(length = unit(2, "mm"), type = "closed")) +
ylab("Anomaly °C") +
theme(plot.background = element_rect(fill = "black"),
panel.background = element_rect(fill = "black"),
legend.background = element_rect(fill = "black"),
legend.text = element_text(colour = "white", size = 10),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_text(colour = "white", size = 10),
axis.text = element_text(colour = "white", size = 10),
axis.line = element_line(colour = "white"),
plot.title = element_text(colour = "white", hjust = 0.5),
plot.subtitle = element_text(colour = "white", hjust = 0.5),
plot.caption = element_text(colour = "white"))
ggplotly(f, tooltip = "text")
```
Carbon-dioxide
=======================================================================
Column {.tabset}
-------------------------------------
### Historic carbon-dioxide levels { .chart-4 }
```{r}
## https://www.co2levels.org/
carbon <- read.csv("carbon.csv")
carbon_data <- ggplot(carbon, aes(x = Year, y = CO2, color = CO2, text = CO2)) +
geom_point(size = 0.2) +
scale_colour_gradient2(low = "lightblue", high = "red", midpoint = 235) +
ylab("Atmospheric concentrations of CO2 (ppm)") +
xlab("Year") +
scale_x_continuous(breaks = c(-800000, -600000, -400000, -200000, 2021)) +
theme(plot.background = element_rect(fill = "black"),
panel.background = element_rect(fill = "black"),
legend.background = element_rect(fill = "black"),
legend.text = element_text(colour = "white", size = 10),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_text(colour = "white", size = 10),
axis.text = element_text(colour = "white", size = 10),
axis.line = element_line(colour = "white"),
plot.title = element_text(colour = "white", hjust = 0.5),
plot.subtitle = element_text(colour = "white", hjust = 0.5),
plot.caption = element_text(colour = "white"))
carbon_data
ggplotly(carbon_data, tooltip = c("Year", "text"))
```
### Carbon-dioxide levels in the Common Era { .chart-4 }
```{r}
## https://www.co2levels.org/
carbon <- read.csv("carbon.csv")
carbon_0 <- filter(carbon, Year >= "0")
carbon_data <- ggplot(carbon_0, aes(x = Year, y = CO2, color = CO2, text = CO2)) +
geom_point(size = 0.2) +
scale_colour_gradient2(low = "lightblue", high = "red", midpoint = 307) +
ylab("Atmospheric concentrations of CO2 (ppm)") +
xlab("Year") +
scale_x_continuous(breaks = c(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1712, 1800, 2021)) +
annotate("text", x = 1712, y = 300, colour = "white", label = "1712: \nInvention of \nsteam engine") +
annotate("segment", xend = 1712, yend = 290, x = 1712, y = 282, colour = "white",
arrow = arrow(length = unit(2, "mm"), type = "closed")) +
theme(plot.background = element_rect(fill = "black"),
panel.background = element_rect(fill = "black"),
legend.background = element_rect(fill = "black"),
legend.text = element_text(colour = "white", size = 10),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_text(colour = "white", size = 10),
axis.text = element_text(colour = "white", size = 10),
axis.line = element_line(colour = "white"),
plot.title = element_text(colour = "white", hjust = 0.5),
plot.subtitle = element_text(colour = "white", hjust = 0.5),
plot.caption = element_text(colour = "white"))
carbon_data
ggplotly(carbon_data, tooltip = c("Year", "text"))
```
Sea-level
=======================================================================
Row
-----------------------------------------------------------------------
### Global sea-level variability in the Common Era { .chart-5 }
```{r}
## https://www.sealevels.org/
sea <- read.csv("sealevel.csv")
sea_0 <- filter(sea, Year >= "0")
col_strip <- brewer.pal(11, "RdBu")
seadata <- ggplot() +
geom_bar(data = sea_0, aes(x = Year, y = mm, fill = mm, text = mm), stat = "identity") +
scale_fill_gradientn(colors = rev(col_strip)) +
ylim(-150, 100) +
ylab("Global sea level height (mm)") +
scale_x_continuous(breaks = c(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2020)) +
theme(plot.background = element_rect(fill = "black"),
panel.background = element_rect(fill = "black"),
legend.background = element_rect(fill = "black"),
legend.text = element_text(colour = "white", size = 10),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_text(colour = "white", size = 10),
axis.text = element_text(colour = "white", size = 10),
axis.line = element_line(colour = "white"),
plot.title = element_text(colour = "white", hjust = 0.5),
plot.subtitle = element_text(colour = "white", hjust = 0.5),
plot.caption = element_text(colour = "white"))
ggplotly(seadata, tooltip = c("Year", "text"))
```