This package loads Kaya-identity data, synthesized from several sources.
To install and load the package, first install either the
pacman
or devtools
package from CRAN:
install.packages("devtools")
::install_github("jonathan-g/kayadata")
devtoolslibrary(kayadata)
or
install.packages("pacman")
library(pacman)
p_load_gh("jonathan-g/kayadata")
Once you’ve installed it, then you just need to use the command
library(kayadata)
to load the package.
Some of the functions the package provides are:
kaya_region_list()
: Get a list of available countries
and regions.get_kaya_data()
: Get data for a specific country.
Example:= get_kaya_data("Mexico")
mexico_data %>% filter(year >= 1965) %>%
mexico_data select(region:ef) %>%
head()
## # A tibble: 6 × 10
## region year P G E F g e f ef
## <ord> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Mexico 2021 0.130 1.21 6.43 374. 9.26 5.34 58.1 310.
## 2 Mexico 2020 0.129 1.15 6.09 358. 8.92 5.30 58.7 311.
## 3 Mexico 2019 0.128 1.25 7.19 449. 9.82 5.74 62.5 359.
## 4 Mexico 2018 0.126 1.26 7.49 468. 9.95 5.96 62.6 373.
## 5 Mexico 2017 0.125 1.23 7.52 477. 9.84 6.12 63.4 388.
## 6 Mexico 2016 0.123 1.20 7.41 469. 9.75 6.16 63.3 390.
project_top_down()
: Project future population, GDP,
energy use, and emissions. Example:= project_top_down("Mexico", 2050)
mexico_2050 mexico_2050
## # A tibble: 1 × 10
## region year P G g E F e f ef
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 Mexico 2050 0.157 2.45 15.6 10.5 577. 4.29 54.9 236.
plot_kaya
: Plot trends in Kaya variables for a given
region or country. Example:= get_kaya_data("United States")
us_kaya plot_kaya(us_kaya, "ef", y_lab = "Carbon intensity of economy",
start_year = 2000, stop_year = 2010, log_scale = TRUE,
trend_line = TRUE, font_size = 10)
= get_kaya_data("World")
world_kaya plot_kaya(world_kaya, "P", start_year = 2000, stop_year = 2010,
log_scale = FALSE, trend_line = FALSE, font_size = 10)
* get_fuel_mix
: Get the fuel mix (coal, gas, oil, nuclear,
and renewables) for a region or country. Example:
= get_fuel_mix("Mexico")
mexico_mix mexico_mix
## # A tibble: 5 × 5
## # Groups: region, year [1]
## region year fuel quads frac
## <chr> <int> <ord> <dbl> <dbl>
## 1 Mexico 2021 Coal 0.220 0.0341
## 2 Mexico 2021 Oil 2.43 0.377
## 3 Mexico 2021 Natural Gas 3.01 0.468
## 4 Mexico 2021 Nuclear 0.102 0.0159
## 5 Mexico 2021 Renewables 0.677 0.105
plot_fuel_mix
: Plot the fuel mix in a donut chartplot_fuel_mix(mexico_mix, font_size = 10)
After you install the package, you can get more help inside RStudio
by typing help(package="kayadata")
in the R console
window.