R/pfim_run.R

Defines functions pfim_run

#' Run PFIM
#'
#' @description Run PFIM calculations based on specified settings object
#' @param ini arguments to be set for PFIM. The argument names correspond to the object names in that you would normally set in stdin.R.
#' @export

pfim_run <- function(ini = list()) {
  out <- list()
  if(file.exists(ini$PFIM)) {
    e <- new.env()
    evalq({
      source(ini$PFIM)
      if(file.exists(paste0(ini$folder, "/", ini$stdin))) {
        sink(file=tempfile())
        suppressMessages({
          suppressWarnings({
            res <- PFIM(ini$stdin)
            sink(file=NULL)
            return(res)
          })
        })
      } else {
        stop("Sorry, stdin script not found, please redefine your settings.")
      }
    }, envir = e)
  } else {
    stop("Sorry, PFIM main script not found, please redefine your settings.")
  }
}
ronkeizer/PFIMwrap documentation built on May 27, 2019, 1:50 p.m.