I'm trying to build a Shiny app which allows users to generate parameterised .Rmd documents based on their inputs. To generate the report, I first copy the report file to a temporary directory, before rendering the file in a new environment. My issue is that my Rmd document relies on other files - images and an .Rda file, which cannot be accessed in these empty environments and I have not found a way to copy them to the temporary directory or new environment. I need these files to be available when the .Rmd document is rendered with render(). Any suggestions?
output$generate <- downloadHandler(filename = "examplereport.html",
content = function(file) {
tempReport <- file.path(tempdir(), "report.Rmd")
file.copy("examplereport.Rmd", tempReport, overwrite = TRUE)
params <- list(parameter1 = input$1, parameter2 = input$2, parameter3 = input$3)
rmarkdown::render(tempReport,
output_file = file,
params = params,
envir = new.env(parent = globalenv())
)
}
)```