title: Download many plots from shinyapp
body: <p>Problem:</p>
  <p>I have a large amount of data I am trying visualize for my users. This may be several hundred plots. In the app currently I am making ggplot2 small multiples using facet_wrap and that's working pretty well up to around 100 plots. However, I want the user to be able to export all of the plots as a record of what they have done and also to be able to visualize all of the plots, not just the first 100. I'm not too worried how it's formatted (ie as a ggforce::facet_wrap_paginate() or as completely separate plots as below).</p>
  <p>I have tried several approaches I found on stack-overflow but nothing seems to be working</p>
  <p>The following code works if I try and export the plots in R but I can't get the download in shiny to work.</p>
  <pre><code>
  library(shiny)
  library(ggplot2)
  
  ui &lt;- fluidPage(
  
    downloadButton(&quot;plot_download&quot;, &quot;Download all plots&quot;),
    plotOutput(&quot;facet_plot&quot;)
  )
  
  server &lt;- function(input, output) {
    
    
    
    data &lt;- reactive({
      
      data.frame(group = rep(LETTERS, each = 100),
                 x = runif(n = 20, min = 10, max = 15),
                 y = runif(n = 20, min = 100, max = 150))
      
    })
    
    
  
      output$facet_plot &lt;- renderPlot({
        data() |&gt;
          ggplot(aes(x,y)) +
          geom_point() +
          facet_wrap(vars(group))
          
      })
      
      
      output$plot_download &lt;- downloadHandler(
        filename = function() {
          paste0(Sys.Date(), &quot;_plot.pdf&quot;)
        },
        content = function(file) {
  
          pdf(file)
          data() |&gt;
            split(by=&quot;group&quot;) |&gt;
            lapply(function(data) {
              gg &lt;- data |&gt;
                ggplot(aes(x,y)) +
                geom_point() 
            })
          dev.off()
  
        }
      )
      
      
  }
  
  
  shinyApp(ui = ui, server = server)
  
  
  </code></pre>