title: Shiny *for* loop to automatically download plots
body: <p>i'm quite new to shiny, and am trying to make a shiny app which allows the user to download all possible combination of a certain data with a simple download button.</p>
  <p>However, it seems that shiny isn't allowing a standard <code>for loop</code> that i've been using outside of shiny</p>
  <p>so basically what I'm trying to do with this reproducible data is to allow users to download all 9 possible scatter plots <code>(1,1),(1,2),(1,3)</code> etc</p>
  <p>I've tried using <code>lapply, isolate, local</code> and so on, but it simple would either make 3 of the same plots, or not work like the current code</p>
  <p>Help would be very, very, very appreciated.</p>
  <p>Thank you in advance</p>
  <p>this is my current UI</p>
  <pre><code>#UI
  library(shiny)
  library(datasets)
  library(ggplot2)
  Test1&lt;- c(3,5,7)
  Test2&lt;- c(21000, 23400, 26800)
  Test3&lt;- c(600, 700, 800)
  df &lt;- data.frame(Test1, Test2, Test3)
  rownames(df)&lt;-colnames(df)
  *ui &lt;- shinyUI(fluidPage(
    titlePanel(&quot;Column Plot&quot;),
    tabsetPanel(
      tabPanel(&quot;First Type&quot;,
               pageWithSidebar(
                 headerPanel('My First Plot'),
                 sidebarPanel(
                   selectInput('xcol', 'X Variable', &quot;&quot;),
                   selectInput('ycol', 'Y Variable', &quot;&quot;, selected = &quot;&quot;),
                   actionButton(inputId = &quot;clicks_3&quot;,label = &quot;Real&quot;),
                 ),
                 mainPanel(
                   plotOutput('MyPlot')
                 )
               )
      )
      
    )
  )
  )
  </code></pre>
  <p>this is my server</p>
  <pre><code>server &lt;- shinyServer(function(input, output, session) {
    data &lt;- reactive({ 
  
      updateSelectInput(session, inputId = 'xcol', label = 'X Variable',
                        choices = names(df), selected = names(df))
      updateSelectInput(session, inputId = 'ycol', label = 'Y Variable',
                        choices = names(df), selected = names(df)[2])
      
      return(df)
    })
    
    output$contents &lt;- renderTable({
      data()
    })
    output$MyPlot &lt;- renderPlot({
      x &lt;- data()[, c(input$xcol, input$ycol)]
      plot(x)
      
    })
    observeEvent(input$clicks_3,{
      for (i in 1:3){
        assign(paste(&quot;Plotinput_&quot;,i,sep = &quot;&quot;),({
          x &lt;- data()[, c(colnames(data())[i], input$ycol)]
          plot(x)
        }))
        lapply(1:3, function(k){local({
          ggsave(plot = eval(parse(text=paste(&quot;Plotinput_&quot;,k,sep = &quot;&quot;))),filename = paste(k,&quot;barplot.png&quot;,collapse = &quot;&quot;))
        })
        })
      }
    })
    
    
  })
  </code></pre>