title: Adding multiple reactive plots and tables to Shiny app
body: <p>I am working on a Shiny app and as I go I have been adding figures and tables in a haphazard way. I would like to have a better framework so that I can flexibly add reactive figures and tables to the output as it develops further. </p>
  
  <p>At the moment I have been using tabPanel and fluidrow to add additional a summary table and a second plot. However I have had trouble adapting this. For example I currently generate 3 plots but have only able to plot 2 at a time. Could anyone show me a way to modify the code to display all three plots (distPlot1, distPlot2, distPlot3) and the summary table on the same page? Ideally in a way that it would be simple to add additional tables and plots in the future.</p>
  
  <p>Thank you in advance.</p>
  
  <p>My current code is below.</p>
  
  <p>ui.R</p>
  
  <pre><code>library(reshape2)
  library(shiny)
  library(ggplot2)
  # Define UI for application that draws a histogram
  fluidPage(
  
    # Application title
    titlePanel("Mutation Probability"),
  
    # Sidebar with a slider input for the number of bins
    sidebarLayout(
      sidebarPanel(
        sliderInput("x", "Probability of mutation (per bp):", 
                    min=1/1000000000000, max=1/1000, value=1/10000000),
  
        sliderInput("y", "Size of region (bp):", 
                    min = 10, max = 10000, value = 1000, step= 100),
  
        sliderInput("z", "Number of samples:", 
                    min = 1, max = 100000, value = 1000, step= 10)
  
      ),
  
      # Show a plot of the generated distribution
      mainPanel(
        tabsetPanel(
          tabPanel("Plot",
            fluidRow(
              splitLayout(cellWidths = c("50%", "50%"), plotOutput("distPlot1"), plotOutput("distPlot3"), plotOutput("distPlot3)"))
            )),
          tabPanel("Summary",  verbatimTextOutput("summary"))
        )
      )
    )
  )
  </code></pre>
  
  <p>server.R</p>
  
  <pre><code>server &lt;- function(input, output) {
  
    mydata &lt;- reactive({
      x &lt;- input$x
      y &lt;- input$y
      z &lt;- input$z
      Muts &lt;- as.data.frame(rpois(100,(x*y*z)))
      Muts
    })
  
  
    output$distPlot1 &lt;- renderPlot({
      Muts &lt;- mydata()
      ggplot(Muts, aes(Muts)) + geom_density() +xlab("Observed variants")
    })
  
    output$distPlot2 &lt;-renderPlot({
      Muts &lt;- mydata()
      ggplot(Muts, aes(Muts)) + geom_histogram() + xlab("Observed variants")
    })
    #get a boxplot working
    output$distPlot3 &lt;-renderPlot({
      Muts &lt;- mydata()
      ggplot(data= melt(Muts), aes(variable, value)) + geom_boxplot() + xlab("Observed variants")
    })
  
    output$summary &lt;- renderPrint({
      Muts &lt;- mydata()
      summary(Muts)
    })
  
  
  }
  </code></pre>