library(eurostat)
library(dplyr)
library(tidyr)
library(plotrix)
dat <- get_eurostat("ten00081")
datl <- label_eurostat(dat)
head(datl)
## unit product
## 1 Thousand TOE (tonnes of oil equivalent) Renewable energies
## 2 Thousand TOE (tonnes of oil equivalent) Renewable energies
## 3 Thousand TOE (tonnes of oil equivalent) Renewable energies
## 4 Thousand TOE (tonnes of oil equivalent) Renewable energies
## 5 Thousand TOE (tonnes of oil equivalent) Renewable energies
## 6 Thousand TOE (tonnes of oil equivalent) Renewable energies
## indic_nrg geo time values
## 1 Primary production Albania 2002-01-01 559.4
## 2 Primary production Austria 2002-01-01 6490.5
## 3 Primary production Belgium 2002-01-01 575.8
## 4 Primary production Bulgaria 2002-01-01 832.1
## 5 Primary production Cyprus 2002-01-01 44.7
## 6 Primary production Czech Republic 2002-01-01 1596.2
Collapsing categories to three levels. Skipping countries with small production of energy.
dict <- c("Solid biofuels (excluding charcoal)" = "Biofuels",
"Biogasoline" = "Biofuels",
"Other liquid biofuels" = "Biofuels",
"Biodiesels" = "Biofuels",
"Biogas" = "Biofuels",
"Hydro power" = "Hydro power",
"Tide, Wave and Ocean" = "Hydro power",
"Solar thermal" = "Wind, solar, waste and Other",
"Geothermal Energy" = "Wind, solar, waste and Other",
"Solar photovoltaic" = "Wind, solar, waste and Other",
"Municipal waste (renewable)" = "Wind, solar, waste and Other",
"Wind power" = "Wind, solar, waste and Other",
"Bio jet kerosene" = "Wind, solar, waste and Other")
energy3 <- datl %>% # Only 2013
filter(time == "2013-01-01",
product != "Renewable energies") %>%
mutate(nproduct = dict[as.character(product)], # just three categories
geo = gsub(geo, pattern=" \\(.*", replacement="")) %>%
select(nproduct, geo, values) %>%
group_by(nproduct, geo) %>%
summarise(svalue = sum(values)) %>%
group_by(geo) %>%
mutate(tvalue = sum(svalue),
svalue = svalue/sum(svalue)) %>%
filter(tvalue > 1000,
!grepl(geo, pattern="^Euro")) %>% # only large countrie
spread(nproduct, svalue)
head(energy3)
## Source: local data frame [6 x 5]
##
## geo tvalue Biofuels Hydro power
## (chr) (dbl) (dbl) (dbl)
## 1 Austria 9466.1 0.5465398 0.3812974720
## 2 Belgium 2929.4 0.6964566 0.0111626954
## 3 Bulgaria 1825.5 0.6418515 0.1921665297
## 4 Croatia 1499.0 0.5007338 0.4589726484
## 5 Czech Republic 3640.2 0.8493215 0.0645843635
## 6 Denmark 3239.7 0.5289687 0.0003395376
## Variables not shown: Wind, solar, waste and Other (dbl)
par(cex=0.75)
triax.plot(as.matrix(energy3[, c(3,5,4)]),
show.grid = TRUE,
label.points = TRUE, point.labels = energy3$geo,cex.ticks=0.75,col.symbols = "red4",
pch = 19)