R/load_wfoparameters.R

Defines functions load_wfoparameters

Documented in load_wfoparameters

####################################################################################
# FILE load_wfoparameters.R
#
#
####################################################################################
# FUNCTION load_wfoparameters
#
#' Load WFO models run parameters from an excel file
#'
#' This is used to run multiple portfolio optimization WFO runs driven
#' by an excel file.
#'
#' @param fname    The excel file name containing the parameters for each
#'                 parametric run.  Must include the proper file path.
#'
#' @param skip     Number of lines to skip at the top
#'
#' @return Returns a dataframe, which each column properly cleaned up and
#'         containing the parameters for the runs.  Each row corresponds to
#'         a unique run.
#' @export
#-----------------------------------------------------------------------------------
load_wfoparameters <- function(fname, data = NA, skip = 0) {

  dfread <- readxl::read_excel(fname, skip = skip)

  # Remove NA rows
  x      <- apply(dfread, 1, FUN = function(x) !all(is.na(x)))
  df     <- dfread[x, ]

  # Keep only rows with ExecuteRun = "Y"
  exerun <- df[, "ExecuteRun"] == "Y"
  df     <- df[exerun, ]

  return(df)

}
jeanmarcgp/ResilientPortfolio documentation built on April 8, 2018, 5:43 p.m.