What's the correct way to structure a Shiny project with a downloadable RMarkdown report?

refactor your plotting code

output$plotname <- renderPlot({
... lots of plotting code ...
}}

-->>

plotname_content <- reactive({
... lots of plotting code ...
})
output$plotname <- renderPlot({
     req(plotname_content())
}}

Thereafter you can continue to use the proposed method of generating downloadable results, but you pass plotname_content as a parameter to your rmarkdown

1 Like