knitr::opts_chunk$set(echo = FALSE) library(dplyr) library(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:
kaya_region_list()
: Get a list of available countries and regions.get_kaya_data()
: Get data for a specific country.
Example: mexico_data = get_kaya_data("Mexico") mexico_data %>% filter(year >= 1965) %>% select(region:ef) %>% head()
project_top_down()
: Project future population, GDP, energy use, and
emissions.
Example: mexico_2050 = project_top_down("Mexico", 2050) mexico_2050
plot_kaya
: Plot trends in Kaya variables for a given region or country.
Example: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
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.