title: Shiny R - Print multiple plots using a loop
body: <p>I have a function in my global.R file that creates a plot:</p>
  
  <pre><code>CreatePlot&lt;-function(mergedFiles,File1, File2) 
  {
    main&lt;- mergedFiles
    csv1&lt;- main[,1:4]
    csv2&lt;- cbind( main[,1],main[,5:7] )
    strikes&lt;- factor(main$Strike,levels=c(main$Strike),ordered=TRUE)
    stacked&lt;- stacked &lt;- data.frame(time=strikes, value =c(c(csv1$Vol), c(csv2$Vol)) ,     variable = rep(c(File1,File2), each=NROW(csv1[,1])))  
  
    g&lt;- ggplot(stacked, aes( x = time,  y=value, colour=variable, group= variable)      )       +   geom_line()  +  xlab("Strike") +geom_point(shape = 7,size = 1) +
      ylab("Volatiltiy") +ggtitle("Plot of Volatilities") + theme(axis.text.x =       element_text(angle = 90, hjust = 1))
    return(g)  
  }
  </code></pre>
  
  <p>I want to create a function to print multiple plots in a loop. Let's say I want 3 plots I am doing something like this in my server.R:</p>
  
  <pre><code>  output$MyList &lt;- renderUI({ 
          main&lt;- mergedFiles() # this is the data for my plots
          g&lt;-CreatePlot(main, input$File1, input$File2) #this calls the create plot function
          for (i in 1:3){
            renderPlot({
                print(g) #for testing purposes I am just trying to print the same plot 3     times
            })
          }
  </code></pre>
  
  <p>})</p>
  
  <p>and my UI.R in the mainPanel:</p>
  
  <pre><code>uiOutput("MyList")
  </code></pre>
  
  <p>When I run this nothing happens. The screen is just blank with no errors. Any ides how to print multiple plots like this using a loop?</p>
  
  <p>Thank yoU!</p>