Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
fbenke-pik committed Sep 13, 2023
1 parent cc2cb0c commit 829d45a
Show file tree
Hide file tree
Showing 3 changed files with 1,341 additions and 1,052 deletions.
47 changes: 27 additions & 20 deletions R/dashboard.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
#' @description Create REMIND dashboard results for single runs
#'
#' @author Renato Rodrigues
#'
#'
#' @param gdx GDX (fulldata.gdx) file path
#' @param statsFile run statistics (runstatistics.rda) file path
#' @param regionMapping regionMapping file name or file path (ex. "regionmappingH12.csv")
#' @param hist historical mif file path
#' @param reportfile REMIND mif report file path
#' @param output_file file name to save the html dashboard
#'
#'
#' @examples
#' \dontrun{
#' # loading required libraries
Expand All @@ -22,39 +22,46 @@
#' @importFrom rmarkdown render
#'
#' @export
#'

dashboard <- function(gdx=NULL, statsFile=NULL, regionMapping=NULL, hist=NULL, reportfile=NULL, output_file=NULL) {
#'

dashboard <- function(gdx = NULL, statsFile = NULL, regionMapping = NULL,
hist = NULL, reportfile = NULL, output_file = NULL) {
# error checking
if(!(!(is.null(gdx)) && file.exists(gdx))){
if (!(!(is.null(gdx)) && file.exists(gdx))) {
warning("REMIND dashboard require a valid gdx file path.")
return()
}
if(!(!(is.null(statsFile)) && file.exists(statsFile))){
if (!(!(is.null(statsFile)) && file.exists(statsFile))) {
warning("REMIND dashboard require a valid run statistics (runstatistics.rda) file path.")
return()
}
if(is.null(regionMapping)){
if (is.null(regionMapping)) {
warning("REMIND dashboard require a regionMapping file.")
return()
}

stats <- NULL
load(file = statsFile)
if(stats$config$gms$optimization == "testOneRegi"){
if (stats$config$gms$optimization == "testOneRegi") {
warning("REMIND dashboard does not support yet testOneRegi runs.")
return()
}

#dashboard markdown file path
markdownPath <- system.file("markdown","dashboard.Rmd",package = "remind")

#set output file if null
if(is.null(output_file))
output_file <- file.path(getwd(),"REMIND_dashboard.html")

# generate dashboard for REMIND
rmarkdown::render(markdownPath, output_file = output_file, params = list(gdx=gdx, statsFile=statsFile, regionMapping=regionMapping, hist=hist, reportfile=reportfile))

# dashboard markdown file path
markdownPath <- system.file("markdown", "dashboard.Rmd", package = "remind2")

# set output file if null
if (is.null(output_file)) {
output_file <- file.path(getwd(), "REMIND_dashboard.html")
}

# generate dashboard for REMIND
rmarkdown::render(markdownPath,
output_file = output_file,
params = list(
gdx = gdx, statsFile = statsFile,
regionMapping = regionMapping,
hist = hist, reportfile = reportfile
)
)
}
Loading

0 comments on commit 829d45a

Please sign in to comment.