Las energías en Europa

23/12/22

Contexto

Con nuestro trabajo pretendemos obtener una visión general de la situación energética actual en Europa.

Sobre todo porque, con el calentamiento global y la guerra de Ucrania, las energías se han convertido últimamente en un tema muy controvertido. Los Estados intentan cada vez más reducir su consumo y utilizar energías renovables.

Así, examinaremos varios puntos:

Introducción

  1. El consumo de las energías
  2. Los tipos de energías utilizadas
  3. La producción de energías
  4. Los precios de las energías

Código
#Paquetes utilizados en el trabajo 
library(readr)
library(tidyverse)
library(plotly)
library(knitr)
library(eurostat)
library(gganimate)


#Datos utilizados
table_data <- "nrg_bal_s"
table_datar <- "nrg_ind_ren"
table_fosil <- "nrg_ind_ffgae"
table_combustible <- "nrg_inf_epc"
table_rw <- "nrg_inf_epc"
table_renewables<- "nrg_inf_epcrw"
table_consumo <- "nrg_cb_sff"
table_consumoR <- "nrg_cb_rw"
table_gas <- "nrg_pc_202"  #DESDE 2007 (GAS)
table_gas07 <- "nrg_pc_202_h"  #ANTES DEL 2007 (GAS)
table_elec <- "nrg_pc_204"  #DESDE 2007 (ELECTRICIDAD)
table_elec07 <- "nrg_pc_204_h"  #ANTES DE 2007 (ELECTRICIDAD)
table_consumoG <- "nrg_cb_gas"  #GAS
table_consumoE <- "nrg_cb_e"  #ELECTRICIDAD
table_inflation <- "tec00118"  #INFLACION de 2010 a 2021

#transformamos los datos
data <- get_eurostat(table_data, time_format = 'raw', keepFlags = TRUE)
df_namesD <- names(data)
data <- label_eurostat(data, code = df_namesD, fix_duplicated = TRUE)
df_dicc <- pjpv.curso.R.2022::pjp_dicc(data)
df_uniques <- pjpv.curso.R.2022::pjp_valores_unicos(data)
data[data == "Germany (until 1990 former territory of the FRG)"] <- "Germany"
paises <- c("Spain","France", "Sweden", "Denmark", "Italy", "Norway", "Germany")
data <- data %>% 
  filter(nrg_bal == "Total energy supply",
         geo %in% paises,
         siec == "Total",
         unit == "Thousand tonnes of oil equivalent") %>%
  select(time, geo, values) %>%
  mutate(time = as.numeric(time))
colnames(data) <- c("year", "country", "value")


datar<- get_eurostat(table_datar, time_format = 'raw', keepFlags = TRUE)
df_namesDr <- names(datar)
datar <- label_eurostat(datar, code = df_namesDr, fix_duplicated = TRUE)
df_dicc <- pjpv.curso.R.2022::pjp_dicc(datar)
df_uniques <- pjpv.curso.R.2022::pjp_valores_unicos(datar)
datar[datar == "Germany (until 1990 former territory of the FRG)"] <- "Germany"
paises <- c("Spain","France", "Sweden", "Denmark", "Italy", "Norway", "Germany")
datar <- datar %>% 
  filter(nrg_bal == "Renewable energy sources") %>%
  filter(geo %in% paises) %>% 
  select(time, geo, values) %>% 
  mutate(time =  as.numeric(time))
colnames(datar) <- c("year", "country", "value")


dfFosil <- get_eurostat(table_fosil, time_format = 'raw', keepFlags = TRUE)
df_namesFosil <- names(dfFosil)
dfFosil <- label_eurostat(dfFosil, code = df_namesFosil, fix_duplicated = TRUE)
df_dicc <- pjpv.curso.R.2022::pjp_dicc(dfFosil)
df_uniques <- pjpv.curso.R.2022::pjp_valores_unicos(dfFosil)
dfFosil[dfFosil == "Germany (until 1990 former territory of the FRG)"] <- "Germany"
str(dfFosil) #Esta como numero VALUES
tibble [1,209 × 10] (S3: tbl_df/tbl/data.frame)
 $ unit_code  : chr [1:1209] "PC" "PC" "PC" "PC" ...
 $ geo_code   : chr [1:1209] "AL" "AT" "BA" "BE" ...
 $ flags_code : chr [1:1209] NA NA NA NA ...
 $ time_code  : chr [1:1209] "2020" "2020" "2020" "2020" ...
 $ values_code: num [1:1209] 58.1 66.8 80.5 76.5 62.9 ...
 $ unit       : chr [1:1209] "Percentage" "Percentage" "Percentage" "Percentage" ...
 $ geo        : chr [1:1209] "Albania" "Austria" "Bosnia and Herzegovina" "Belgium" ...
 $ flags      : chr [1:1209] NA NA NA NA ...
 $ time       : chr [1:1209] "2020" "2020" "2020" "2020" ...
 $ values     : num [1:1209] 58.1 66.8 80.5 76.5 62.9 ...
Código
dfFosil <- dfFosil %>% mutate(time =  as.numeric(time))
dfFosil <- dfFosil %>% 
  select(time, geo, values) %>% 
  filter(geo %in% paises)
#paises <- c("Spain","France", "Sweden", "Denmark", "Italy", "Norway", "Germany")


df <- get_eurostat(table_combustible, time_format = 'raw', keepFlags = TRUE)
df_names <- names(df)
df <- label_eurostat(df, code = df_names, fix_duplicated = TRUE)
df_dicc <- pjpv.curso.R.2022::pjp_dicc(df)
df_uniques <- pjpv.curso.R.2022::pjp_valores_unicos(df)
rm(df_dicc, df_uniques)
df[df == "Germany (until 1990 former territory of the FRG)"] <- "Germany"
paises <- c("Spain","France", "Sweden", "Denmark", "Italy", "Norway", "Germany")
dfEngFos <- df %>% filter (siec == c("Nuclear fuels and other fuels n.e.c.", "Combustible fuels"),
                   geo %in% paises) %>%
  select(time,geo,unit, values, operator) %>%
  mutate(time = as.numeric(time)) %>%
  group_by(geo, time) %>%
  summarise(Total = sum(values)) %>% 
  filter(Total != 0)
colnames(dfEngFos) <- c("pais", "anyo", "fosiles")



df_rw<- get_eurostat(table_rw, time_format = 'raw', keepFlags = TRUE)
df_namesrw <- names(df_rw)
df_rw <- label_eurostat(df_rw, code = df_namesrw, fix_duplicated = TRUE)
df_dicc <- pjpv.curso.R.2022::pjp_dicc(df_rw)
df_uniques <- pjpv.curso.R.2022::pjp_valores_unicos(df_rw)
rm(df_dicc, df_uniques)
df_rw[df_rw == "Germany (until 1990 former territory of the FRG)"] <- "Germany"
paises <- c("Spain","France", "Sweden", "Denmark", "Italy", "Norway", "Germany")
eng_rw <- c("Tide, wave, ocean", "Solar photovoltaic",
            "Solar thermal", "Wind", "Geothermal",
            "Pumped hydro power", "Mixed hydro power",
            "Pure hydro power", "Hydro")
dfEngR <- df_rw %>% filter (siec %in% eng_rw,
                           geo %in% paises) %>%
  select(time,geo,unit, values, operator) %>%
  mutate(time = as.numeric(time)) %>%
  group_by(geo, time) %>%
  summarise(Total = sum(values)) %>% 
  filter(Total != 0)
colnames(dfEngR) <- c("pais", "anyo", "fosiles")


df_consumo<- get_eurostat(table_consumo, time_format = 'raw', keepFlags = TRUE)
df_namesC <- names(df_consumo)
df_consumo <- label_eurostat(df_consumo, code = df_namesC, fix_duplicated = TRUE)
df_diccC <- pjpv.curso.R.2022::pjp_dicc(df_consumo)
df_uniquesC <- pjpv.curso.R.2022::pjp_valores_unicos(df_consumo)
rm(df_diccC, df_uniquesC)
df_consumo[df_consumo == "Germany (until 1990 former territory of the FRG)"] <- "Germany"
df_consumo <- df_consumo %>% select(time, geo, values, siec)
df_consumo <- df_consumo %>% mutate(time =  as.numeric(time))
paises <- c("Spain","France", "Sweden", "Denmark", "Italy", "Norway", "Germany")
df_consumo <- df_consumo %>%
  filter (geo %in% paises) %>%
  group_by(geo, time) %>%
  summarise(Total = sum(values))
colnames(df_consumo) <- c("pais", "anyo", "consumo total de energias no renovables")



df_consumoR <- get_eurostat(table_consumoR, time_format = 'raw', keepFlags = TRUE)
df_namesCR <- names(df_consumoR)
df_consumoR <- label_eurostat(df_consumoR, code = df_namesCR, fix_duplicated = TRUE)
df_diccCR <- pjpv.curso.R.2022::pjp_dicc(df_consumoR)
df_uniquesCR <- pjpv.curso.R.2022::pjp_valores_unicos(df_consumoR)
rm(df_diccCR, df_uniquesCR)
df_consumoR[df_consumoR == "Germany (until 1990 former territory of the FRG)"] <- "Germany"
df_consumoR <- df_consumoR %>% select(time, geo, values, siec)
df_consumoR <- df_consumoR %>% mutate(time =  as.numeric(time))
paises <- c("Spain","France", "Sweden", "Denmark", "Italy", "Norway", "Germany")
df_consumoR <- df_consumoR %>%
  filter (geo %in% paises) %>%
  group_by(geo, time) %>%
  summarise(Total = sum(values))
colnames(df_consumoR) <- c("pais", "anyo", "consumo total de energias renovables")



dfGas <- get_eurostat(table_gas, time_format = 'raw', keepFlags = TRUE)
df_namesGas <- names(dfGas)
dfGas <- label_eurostat(dfGas, code = df_namesGas, fix_duplicated = TRUE)
df_dicc <- pjpv.curso.R.2022::pjp_dicc(dfGas)
df_uniques <- pjpv.curso.R.2022::pjp_valores_unicos(dfGas)
rm(df_dicc, df_uniques)
dfGas[dfGas == "Germany (until 1990 former territory of the FRG)"] <- "Germany"
dfGas <- dfGas %>% mutate(time =  as.numeric(time_code))
paises <- c("Spain","France", "Sweden", "Denmark", "Italy", "Norway", "Germany")
dfGas <- dfGas %>%
  filter(tax == "Excluding taxes and levies",
         currency == "Euro",
         unit == "Gigajoule (gross calorific value - GCV)",
         geo %in% paises) %>%
  mutate(fecha = lubridate::yq(time_code)) %>% 
  mutate(periodo = lubridate::year(fecha)) %>%
  select(periodo,geo, geo_code,unit, currency, values, consom) %>% 
  group_by(geo, periodo, geo_code) %>%
  summarise(Total = sum(values)) %>%
  filter(periodo > 2007)


dfGas07 <- get_eurostat(table_gas07, time_format = 'raw', keepFlags = TRUE)
df_namesGas07 <- names(dfGas07)
dfGas07 <- label_eurostat(dfGas07, code = df_namesGas07, fix_duplicated = TRUE)
df_dicc07 <- pjpv.curso.R.2022::pjp_dicc(dfGas07)
df_uniques07 <- pjpv.curso.R.2022::pjp_valores_unicos(dfGas07)
rm(df_dicc07, df_uniques07)
dfGas07[dfGas07 == "Germany (until 1990 former territory of the FRG)"] <- "Germany"
dfGas07 <- dfGas07 %>% mutate(time =  as.numeric(time_code))
paises <- c("Spain","France", "Sweden", "Denmark", "Italy", "Norway", "Germany")
dfGas07 <- dfGas07 %>%
  filter(tax == "Excluding taxes and levies",
         currency == "Euro",
         unit == "Gigajoule (gross calorific value - GCV)",
         geo %in% paises) %>%
  mutate(fecha = lubridate::yq(time_code)) %>% 
  mutate(periodo = lubridate::year(fecha))  %>%
  select(periodo,geo, geo_code,unit, currency, values, consom) %>% 
  group_by(geo, periodo, geo_code) %>%
  summarise(Total = sum(values)) %>%
  filter(periodo < 2008)
 



dfElec <- get_eurostat(table_elec, time_format = 'raw', keepFlags = TRUE)
df_namesElec <- names(dfElec)
dfElec <- label_eurostat(dfElec, code = df_namesElec, fix_duplicated = TRUE)
df_dicc <- pjpv.curso.R.2022::pjp_dicc(dfElec)
df_uniques <- pjpv.curso.R.2022::pjp_valores_unicos(dfElec)
rm(df_dicc, df_uniques)
dfElec[dfElec == "Germany (until 1990 former territory of the FRG)"] <- "Germany"
dfElec <- dfElec %>% mutate(time =  as.numeric(time_code))
paises <- c("Spain","France", "Sweden", "Denmark", "Italy", "Norway", "Germany")
dfElec <- dfElec %>%
  filter(tax == "Excluding taxes and levies",
         currency == "Euro",
         consom != "Consumption of kWh - all bands",
         geo %in% paises) %>%
  mutate(fecha = lubridate::yq(time_code)) %>% 
  mutate(periodo = lubridate::year(fecha)) %>%
  select(periodo, geo, geo_code, unit, currency, values, consom) %>% 
  group_by(geo, periodo, geo_code) %>%
  summarise(Total = sum(values)) %>%
  filter(periodo > 2007)



dfElec07 <- get_eurostat(table_elec07, time_format = 'raw', keepFlags = TRUE)
df_namesElec07 <- names(dfElec07)
dfElec07 <- label_eurostat(dfElec07, code = df_namesElec07, fix_duplicated = TRUE)
df_dicc <- pjpv.curso.R.2022::pjp_dicc(dfElec07)
df_uniques <- pjpv.curso.R.2022::pjp_valores_unicos(dfElec07)
rm(df_dicc, df_uniques)
dfElec07[dfElec07 == "Germany (until 1990 former territory of the FRG)"] <- "Germany"
dfElec07 <- dfElec07 %>% mutate(time =  as.numeric(time_code))
paises <- c("Spain","France", "Sweden", "Denmark", "Italy", "Norway", "Germany")
dfElec07 <- dfElec07 %>%
  filter(tax == "Excluding taxes and levies",
         currency == "Euro",
         consom != "Consumption of kWh - all bands",
         geo %in% paises) %>%
  mutate(fecha = lubridate::yq(time_code)) %>% 
  mutate(periodo = lubridate::year(fecha)) %>%
  select(periodo, geo, geo_code, unit, currency, values, consom) %>% 
  group_by(geo, periodo, geo_code) %>%
  summarise(Total = sum(values)) %>%
  filter(periodo < 2008)


df_consumoG <- get_eurostat(table_consumoG, time_format = 'raw', keepFlags = TRUE)
df_namesG <- names(df_consumoG)
df_consumoG <- label_eurostat(df_consumoG, code = df_namesG, fix_duplicated = TRUE)
df_diccCG <- pjpv.curso.R.2022::pjp_dicc(df_consumoG)
df_uniquesCG <- pjpv.curso.R.2022::pjp_valores_unicos(df_consumoG)
rm(df_diccCG, df_uniquesCG)
df_consumoG[df_consumoG == "Germany (until 1990 former territory of the FRG)"] <- "Germany"
paises <- c("Spain","France", "Sweden", "Denmark", "Italy", "Norway", "Germany")
df_consumoG <- df_consumoG %>% mutate(time =  as.numeric(time))
df_consumoG <- df_consumoG %>% 
  filter(unit == "Terajoule (gross calorific value - GCV)") %>%
  select(time, geo, values, siec, unit) %>%
  filter(geo %in% paises)  %>%
  group_by(geo, time) %>%
  summarise(Total = sum(values))



df_consumoE <- get_eurostat(table_consumoE, time_format = 'raw', keepFlags = TRUE)
df_namesE <- names(df_consumoE)
df_consumoE <- label_eurostat(df_consumoE, code = df_namesE, fix_duplicated = TRUE)
df_diccCE <- pjpv.curso.R.2022::pjp_dicc(df_consumoE)
df_uniquesCE <- pjpv.curso.R.2022::pjp_valores_unicos(df_consumoE)
rm(df_diccCE, df_uniquesCE)
df_consumoE[df_consumoE == "Germany (until 1990 former territory of the FRG)"] <- "Germany"
paises <- c("Spain","France", "Sweden", "Denmark", "Italy", "Norway", "Germany")
df_consumoE <- df_consumoE %>% mutate(time =  as.numeric(time))
df_consumoE <- df_consumoE %>%
  select(time, geo, values, siec, unit) %>%
  filter(geo %in% paises)  %>%
  group_by(geo, time) %>%
  summarise(Total = sum(values))



df_inflation <- get_eurostat(table_inflation, time_format = 'raw', keepFlags = TRUE)
df_namesInf <- names(df_inflation)
df_inflation <- label_eurostat(df_inflation, code = df_namesInf, fix_duplicated = TRUE)
df_dicc <- pjpv.curso.R.2022::pjp_dicc(df_inflation)
df_uniques <- pjpv.curso.R.2022::pjp_valores_unicos(df_inflation)
rm(df_dicc, df_uniques)
df_inflation[df_inflation == "Germany (until 1990 former territory of the FRG)"] <- "Germany"
paises <- c("Spain","France", "Sweden", "Denmark", "Italy", "Norway", "Germany")
df_inflation <- df_inflation %>% mutate(time =  as.numeric(time))
df_inflation0 <- df_inflation %>%
  select(time, geo, geo_code, values) %>%
  filter(geo %in% paises)
colnames(df_inflation0) <- c("Anyo", "Pais", "geo_code","Inflacion")

El consumo de las energías globales

La evolución del consumo de energías

Comparación del consumo de las energías para cada año

Países que más consumen

year country value
2020 Germany 280169.38
2020 France 221095.55
2020 T<fc>rkiye 146134.49
2020 Italy 140100.48
2020 Spain 110218.90
2020 Poland 102521.54
2020 Ukraine 86551.03
2020 Netherlands 69719.52
2020 Belgium 50241.27
2020 Sweden 44863.79
2020 Czechia 40096.94
2020 Romania 32163.21
2020 Austria 31910.03
2020 Finland 31833.37
2020 Norway 28288.90
2020 Hungary 26051.55
2020 Portugal 20863.49
2020 Greece 20093.12
2020 Bulgaria 17698.18
2020 Slovakia 16417.67

El consumo según los tipos de energías

Las energías renovables

Las energías fósiles

Comparación energías renovables/fósiles

La producción según los tipos de energías

Energias fósiles

Energías renovables

Balance consumo/produccíon

Los precios de las energías

El gas

La electricidad

La correlación precios/inflación

Conclusíon

  • Aunque el consumo global de energía se ha mantenido relativamente estable durante los años, los tipos de energías consumidas han combiado. El consumo y la producción de energías renovables han aumentado, mientras que el consumo de combustibles fósiles ha disminuido un poco. Esto es muy positivo para el futuro, pero aún los países tienen que hacer esfuerzos, sobre todo en la producción de combustibles fósiles, que sigue siendo importante.

  • No observamos una relación entre el consumo y la producción de combustibles fósiles. Esto se debe a que la producción es muy grande, por lo que hay muchas importaciones y exportaciones. Sin embargo, esto es muy diferente en el caso de las energías renovables. Los países suelen consumir su propia producción porque es baja.

  • En cuanto a la relación precio/inflación, la relación parece bastante clara para la mayoría de países. Y es que cuando aumenta la inflación, aumentan los precios, ya sean de gas o de electricidad, y durante uno o dos años, esto se ajustan los precios. Caso contrario si cae la inflación.

¡¡¡Gracias por su atención y feliz navidad!!!