-
Notifications
You must be signed in to change notification settings - Fork 2
/
README.Rmd
89 lines (81 loc) · 2.95 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
---
title: "kayadata"
author: "Jonathan Gilligan"
date: "2024-07-07"
output: github_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
echo = FALSE,
comment = "#>",
fig.path="man/figures/README-",
out.width = "100%"
)
library(tidyverse)
# library(pacman)
# p_load_current_gh("jonathan-g/kayadata")
library(kayadata)
```
# kayadata
<!-- badges: start -->
[![CRAN Status Badge](https://www.r-pkg.org/badges/version-last-release/kayadata)](https://cran.r-project.org/package=kayadata)
[![DOI](https://zenodo.org/badge/108232691.svg)](https://zenodo.org/badge/latestdoi/108232691)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![R-CMD-check](https://github.com/jonathan-g/kayadata/workflows/R-CMD-check/badge.svg)](https://github.com/jonathan-g/kayadata/actions)
[![pkgdown](https://github.com/jonathan-g/kayadata/workflows/pkgdown/badge.svg)](https://github.com/jonathan-g/kayadata/actions)
<!-- badges: end -->
This package loads Kaya-identity data, synthesized from several sources.
To install the package from CRAN:
```{r initialize, echo=TRUE, eval=FALSE}
install.packages("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:
```{r get-kaya-data, echo=TRUE}
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:
```{r project-top-down, echo=TRUE}
mexico_2050 = project_top_down("Mexico", 2050)
mexico_2050
```
* `plot_kaya`: Plot trends in Kaya variables for a given region or country.
Example:
```{r plot-kaya, echo=TRUE}
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)
```
```{r plot-kaya-world, echo=TRUE}
world_kaya = get_kaya_data("World")
plot_kaya(world_kaya, "P", start_year = 2000, stop_year = 2010, log_scale = FALSE,
trend_line = FALSE)
```
* `get_fuel_mix`: Get the fuel mix (coal, gas, oil, nuclear, and renewables)
for a region or country.
Example:
```{r get-fuel-mix, echo=TRUE}
mexico_mix = get_fuel_mix("Mexico")
mexico_mix
```
* `plot_fuel_mix`: Plot the fuel mix in a donut chart
```{r plot-fuel-mix, echo=TRUE}
plot_fuel_mix(mexico_mix)
```
After you install the package, you can get more help inside RStudio by typing
`help(package="kayadata")` in the R console window.
## Code of conduct
Please note that this project is released with a [Contributor Code of
Conduct](https://jonathan-g.github.io/kayadata/CODE_OF_CONDUCT.html). By
participating in this project you agree to abide by its terms.