GTAPSSP: SSPs for GTAP Framework
1 Introduction
This tutorial demonstrates the utilization of the gtapssp package in R for data processing. It covers various steps such as reading, transforming, and analyzing data, making it suitable for both beginners and advanced users.
The package provides optimized and user-friendly functions to download SSP data, interpolate data using spline and beers methods. The gtapssp functions is accompanied by detailed manual, you can also access this manual by pressing F1
on the function name in RStudio.
2 Installation
To use the gtapssp package, it’s necessary to have R installed on your computer, which can be downloaded from here. Additionally, we recommend downloading RStudio, available at here, which provides a user-friendly interface to work with R.
R is a versatile programming language, with a focus on statistical computing. It is a big part of academic research in the social sciences. R is free and open-source and runs on Windows, Mac OS X, and Linux.
- Download the R installer from the Comprehensive R Archive Network (CRAN).
- Choose the appropriate installer for your operating system and computer architecture (32-bit or 64-bit).
- If on Mac, you will need to know if you are using an Intel or Apple Silicon (M1) processor.
Run the installer and follow the instructions.
We recommend install R Tools. Many of the packages we will be using in this course require R Tools to be installed.
If you are on Windows:
Download the latest version of the software from the R Tools for Windows page.
Run the installer and follow the instructions.
If you are on Mac:
First, install the Xcode Command Line Tools. Go to the R Tools for Mac page and follow the instructions. Note: the precise instructions will vary according to the version of macOS you are using.
Install the gfortran compiler, as also indicated on the R Tools for Mac page.
Python installation is only required if you plan to download other versions of SSPs datasets from the IIASA. The gtapssp
package includes a built-in default dataset, so installing Python is optional unless you wish to access the latest or alternative datasets from IIASA’s API (developed in Python).
Python is a general-purpose programming language that is becoming increasingly popular in the social sciences. It is free and open-source and runs on Windows, Mac OS X, and Linux.
Download Python from the Python Software Foundation.
Run the installer and make sure to check the box that says “Add Python to PATH” before clicking on “Install Now”.
We recommend RStudio as IDE for R.
RStudio is by far the most popular IDE used by R programmers. It is free and open-source and comes with a console and syntax-highlighting editor that supports direct code execution, as well as tools for plotting, history, debugging, and workspace management.
Alternative: If you are already familiar with Visual Studio Code (VS Code), say because you have already used it for Python, you can also use it for R programming. You will need to do a bit of configuration to get it to work, though. If you choose to use VS Code, download and install the R Extension for Visual Studio Code and remember to follow the instructions on the Getting Started section of the extension page.
You can install the development version of gtapssp from GitHub with:
# If the devtools package is not already installed, please run the disabled line below.
# install.packages("devtools")
::install_github("tsimonato/gtapssp") devtools
3 One-Line Workflow
If you’d like to execute the entire pipeline described in this tutorial with minimal effort, you can use the gtapssp::iiasa_gtap()
function. This function runs all steps, including data aggregation, interpolation, expansion, label merging, and optional file exports.
Here’s an example:
<- gtapssp::iiasa_gtap()
ssp_data
ssp_data
This function provides flexibility to either return the processed dataset for further use in R or save the output in .har or .csv formats:
# Run the entire pipeline and save the output as a .HAR file
::iiasa_gtap(outFile = "gtap_ssp.har")
gtapssp# Or save as a .CSV file
::iiasa_gtap(outFile = "gtap_ssp.csv") gtapssp
Below is a spatial representation of the population data. The map below highlights population estimates for females, aged 65 and above in the year 1950, under the SSP1 scenario. The data is sourced from the IIASA-WiC POP 2023 dataset.
Show the code
# If the gtaptools package is not already installed, please run the disabled line below.
# devtools::install_github("tsimonato/gtaptools")
<- ssp_data |>
data_map ::mutate(iso_a3 = ISO) |>
dplyr::filter(MOD == "IIASA-WiC POP 2023",
dplyr== "SSP1",
SCE == "FEML",
GND == "P65UP",
AGE == "Y1950")
YRS # Example: Plot a map using the `plot_map` function
::plot_map(
gtaptoolsinput_data = data_map, # Your data frame
value_var = "value", # Replace with the column name for numeric values to plot
colors = "viridis",
legend_title = "Million people", # Replace with a title for your legend
)