Xinxin Yang's avatar
Xinxin Yang committed
###########################################################################
###########################################################################
###                                                                     ###
###                             Installation:                           ###
###                INSTALL R PACKAGES FROM GITLAB, GITHUB               ###
###                                                                     ###
###########################################################################
###########################################################################

# Install R packages from Gitlab, Github.

# Install the released version of devtools from CRAN:
install.packages("devtools")

# Install the latest version of packages from Github
devtools::install_github("briatte/tidykml")
devtools::install_github("GAMS-dev/gdxrrw/gdxrrw")

# Install the latest version of packages from Gitlab
devtools::install_git("https://git-dmz.thuenen.de/mindstep/caprir.git")
devtools::install_git("https://git-dmz.thuenen.de/mindstep/capriv.git")

# load packages
requiredPackages = c('caprir', 'capriv', 'gdxrrw', 'usethis', 'hablar', 'tibble',
                     'networkD3', 'readxl', 'tidyr', 'reshape2', 'data.table',
                     'plotly', 'gt', 'ggtext', 'rlang', 'Hmisc', 'webshot', 'XML','dplyr')
Xinxin Yang's avatar
Xinxin Yang committed
for(p in requiredPackages){
  if(!require(p,character.only = TRUE))install.packages(p)
  library(p,character.only = TRUE, quietly = TRUE)}


if("dplyr" %in% (.packages())){
  detach("package:dplyr", unload=TRUE)
  detach("package:plyr", unload=TRUE)
}
library(plyr)
library(dplyr)

Xinxin Yang's avatar
Xinxin Yang committed
# set gams path, if necessary
gamsPath <- "D://gams//win64//24.9"
igdx(gamsPath)


###########################################################################
###########################################################################
###                                                                     ###
###                             SETUP:                                  ###
###                     Set capri directory                             ###
###                                                                     ###
###########################################################################
###########################################################################

capri.dir <- "D:/public/yang/2021"
xml.dir <- paste0(capri.dir, "/tstrunk/GUI/views")
gdx.dir <- paste0(capri.dir, "/tstrunk/output/results/capmod")

# extract from xml files and save in project directory
xml_data(xml.dir = xml.dir)

# load capri activities, products, region...
files <- list.files(path = paste0(getwd(), "/data"), pattern = "\\.rds$", full.names = TRUE)
for (file in files) load(file)