# source: https://github.com/bydata/30DayChartChallenge/blob/main/2023/22/22-green-energy.R
library(tidyverse)
library(ggtext)
library(showtext)
showtext_auto()
# Set fonts
font_add_google("Fira Sans","fira")
library(eurostat)
#base_path <- here("2023", "22")
#' Source: Eurostat
<- get_eurostat("nrg_ind_ren",
df time_format = "num",
type = "code" # get variable codes and labels
)
<- label_eurostat(df, code = "geo", fix_duplicated = TRUE)
df
# which countries?
unique(df$geo)
unique(df$geo_code)
<- c("AT", "BE", "BG", "CY", "CZ", "DE", "DK", "EE", "EL",
eu_geo_codes "ES", "EU27_2020", "FI", "FR", "HR", "HU", "IE", "IT", "LT",
"LU", "LV", "MT", "NL", "PL", "PT", "RO", "SE", "SI", "SK" )
%>%dim
df
<- df %>%
df1 filter(geo_code %in% eu_geo_codes) %>%
mutate(geo = case_match(
geo,"Germany (until 1990 former territory of the FRG)" ~ "Germany",
"European Union - 27 countries (from 2020)" ~ "EU 27",
.default = geo
))
%>%count(nrg_bal)
df1
%>%
df1filter(nrg_bal=="Renewable energy sources in transport")
%>%#count(geo)%>%View
df1 ggplot(aes(time,values,group=geo,color=geo))+
geom_line(color="grey80")+
geom_line(data=df1%>%
filter(geo%in%c("Italy","EU 27","Spain","Germany","France")),
inherit.aes = TRUE)+
facet_wrap(~nrg_bal,scales = "free_y")+
::scale_color_calc()+
ggthemeslabs(title="Renewable energy sources",
color="",
caption="DataSource: {eurostat} | #30DayChartChallenge day22: Green Energy\nDataViz: Federica Gazzelloni")+
::theme_calc()+
ggthemestheme(text = element_text(family="fira"),
plot.title = element_text(size=24),
axis.title.x = element_blank(),
strip.background = element_rect(color="#be2d42",fill="#be2d42"),
strip.text = element_text(color="white"))
Gazzelloni F. (2023), Data Visualization: Green energy
As for the term “Green Energy”, it typically refers to energy that is produced from renewable sources, such as wind, solar, hydro, and geothermal power.