The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Getting Started with the kayadata Package

Jonathan Gilligan

2019-12-21

kayadata

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")
devtools::install_github("jonathan-g/kayadata")
library(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:

mexico_data = get_kaya_data("Mexico") 
mexico_data %>% filter(year >= 1965) %>% 
  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  2022 0.128  1.24  8.27  506.  9.76  6.65  61.1  407.
## 2 Mexico  2021 0.127  1.21  7.57  450.  9.53  6.27  59.4  373.
## 3 Mexico  2020 0.126  1.15  7.04  418.  9.15  6.11  59.3  363.
## 4 Mexico  2019 0.125  1.25  7.64  480. 10.0   6.10  62.8  383.
## 5 Mexico  2018 0.124  1.26  7.73  489  10.1   6.16  63.2  390.
## 6 Mexico  2017 0.123  1.23  7.83  503. 10.0   6.37  64.3  410.
mexico_2050 = project_top_down("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.
us_kaya = get_kaya_data("United States")
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)

world_kaya = get_kaya_data("World")
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:

mexico_mix = get_fuel_mix("Mexico")
mexico_mix
## # A tibble: 5 × 5
## # Groups:   region, year [1]
##   region  year fuel         quads   frac
##   <chr>  <int> <ord>        <dbl>  <dbl>
## 1 Mexico  2022 Coal        0.237  0.0286
## 2 Mexico  2022 Oil         3.91   0.472 
## 3 Mexico  2022 Natural Gas 3.30   0.399 
## 4 Mexico  2022 Nuclear     0.0948 0.0115
## 5 Mexico  2022 Renewables  0.749  0.0905
plot_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.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.