Created
May 9, 2019 19:21
-
-
Save vanatteveldt/b4513d4399042b6b9cad79600a98826f to your computer and use it in GitHub Desktop.
This file contains 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) | |
data = read_csv("https://www.ofgem.gov.uk/node/98510/revisions/321984/csv") %>% separate(Date, into=c("q", "y")) %>% gather(-q, -y, key="type", value="perc") | |
data %>% group_by(y, type) %>% summarize(p = mean(perc)) %>% filter(type %in% c("Gas", "Coal", "Nuclear", "Bioenergy", "Wind (onshore and offshore) and Solar")) %>% | |
ggplot() + geom_line(aes(x=as.numeric(y), y=p, colour=type)) + ggthemes::theme_economist() + xlab("Year") + ylab("% of electricity generated") | |
data %>% group_by(y, type) %>% summarize(p = mean(perc)) %>% | |
mutate(type=case_when(type %in% c("Gas", "Coal") ~ "Gas & Coal", type %in% c("Bioenergy", "Wind (onshore and offshore) and Solar") ~ "Wind & Solar & Bio", T ~ "other")) %>% | |
group_by(y, type) %>% summarize(p = sum(p)) %>% | |
ggplot() + geom_line(aes(x=as.numeric(y), y=p, colour=type)) + ggthemes::theme_economist() + xlab("Year") + ylab("% of electricity generated") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment