title: R/Shiny plots do not show in the browser
body: <p>I started playing with Shiny recently. I was trying to write something to demonstrate central limit theorem. my code is as follows:</p>
  
  <p>ui.R:</p>
  
  <pre><code>#****************************************ui.R file code*****************************
  
  library(shiny)
  shinyUI(pageWithSidebar(headerPanel("Central Limit Theorem"),
                          sidebarPanel(selectInput("Distribution", 
                                                   "Distribution:", 
                                                   list("normal", "lognormal")),
                                                   br(),
                                                   sliderInput("sam_size", 
                                                                "Sample size:", 
                                                                min = 5, 
                                                                max = 500, 
                                                                value = 5)
                          ),
                          mainPanel(tabPanel("Plot", plotOutput("plot")))
  ))
  </code></pre>
  
  <p>server.R:</p>
  
  <pre><code>#****************************************server.R file code**************************
  library(shiny)
  shinyServer(function(input, output){
          data &lt;- reactive(function(){Distribution &lt;- switch(input$Distribution,
                                                             normal = rnorm,
                                                             lognormal = rlnorm,
                                                             rnorm
                                                             )
                                      Distribution(input$sam_size*2000)})
  
          output$plot &lt;- reactive(function(){
                              Distribution &lt;- input$Distribution
                              sam_size &lt;- input$sam_size
                              temp &lt;- matrix(data(), ncol=2000)
                              xbars &lt;- colMeans(temp)
                              hist(xbars, main=paste("Sampling Distribution of the Mean Based on a", Distribution,
                           "distribution with n =", sam_size))})
  })
  </code></pre>
  
  <p>When I tried to run the code using <code>runApp()</code>, below is what I got. As you can see, the plot is not displayed. </p>
  
  <p><img src="https://i.stack.imgur.com/laV7y.png" alt="enter image description here"></p>
  
  <p>The weird part is that, when I went back to my Rstudio, and pressed "Esc" to exit the app, the plot displayed in my Rstudio as shown below:</p>
  
  <p><img src="https://i.stack.imgur.com/5XjZS.png" alt="enter image description here"></p>
  
  <p>I wonder if anyone knows what the problem is with my code. Thanks!!</p>