0

I have a reasonably complex Shiny App (several modules) that allows users to fiddle with many different parameters and generate a lot of plots. I want to add the ability for users to download the output they've generated in the Shiny App as a reproducible RMarkdown.

I have read through https://shiny.rstudio.com/articles/generating-reports.html and understand how to do this with a separate Rmarkdown file. However, all of my plotting/data manipulation code is in the Shiny app and it seems like poor practice (violation of DRY) to copy it over to an RMarkdown file -- then any time I want to change the plotting code I would need to change it twice.

What's the correct way to do this so that I don't have to maintain two sets of the same code?

  • you can parameterize rmarkdown reports. I'd probably use the shiny parameters as inputs to the render function. – cory Apr 07 '21 at 19:23
  • I started out that way, but I don't want to keep a reasonably complex web app inside of an RMarkdown document, either. I have several hundred lines of UI/Server code, most of which is completely unrelated to the data manipulation/plotting part that makes up the report. – nlarusstone Apr 07 '21 at 19:51
  • Just FYI this was [cross-posted on Rstudio as well](https://community.rstudio.com/t/whats-the-correct-way-to-structure-a-shiny-project-with-a-downloadable-rmarkdown-report/101239/3) – nlarusstone Apr 07 '21 at 21:04
  • 1
    Save the plots as png or whatever and pick those up in your rmarkdown report? – cory Apr 08 '21 at 11:42
  • Have you also looked into Bookmarking with Shiny? This allows the users to save the Shiny app at it's current state, and then they can copy the URL of the bookmarked state for sharing as well, just giving another suggestion [bookmarking in Shiny](https://shiny.rstudio.com/articles/bookmarking-state.html) – Daniel_j_iii Apr 10 '21 at 22:23

0 Answers0