R/server-solve-report.R

Defines functions report

Documented in report

#' Report.
#'
#' @param problem.info 
#' @param results 
#' @param input 
#'
#' @return
#' @export
#'
#' @examples
report <- function(problem.info, results, input){
  downloadHandler(
    # For PDF output, change this to "report.pdf"
    filename = "report.html",
    content = function(file) {
      # Copy the report file to a temporary directory before processing it, in
      # case we don't have write permissions to the current working dir (which
      # can happen when deployed).
      tempReport <- file.path(tempdir(), "report.Rmd")
      file.copy("report.Rmd", tempReport, overwrite = TRUE)
      
      # Set up parameters to pass to Rmd document
      params <- list(info=problem.info, results=results, input=input)
      
      # Knit the document, passing in the `params` list, and eval it in a
      # child of the global environment (this isolates the code in the document
      # from the code in this app).
      rmarkdown::render(tempReport, output_file = file,
                        params = params,
                        envir = new.env(parent = globalenv())
      )
    }
  )
}
mjginzo/SAA documentation built on May 24, 2019, 5:05 a.m.