title: How to correctly output Plotly plots in shiny?
body: <p>I am trying to make a shiny app based on New York crime historical data. I am using single shiny page approach. Here's the data: <a href="https://data.world/data-society/nyc-crime-data" rel="noreferrer">https://data.world/data-society/nyc-crime-data</a></p>
  
  <p>For some reason when I select the year to output the crime statistics, my output gets outputted only in the Viewer of RStudio and not on the main panel of the Shiny popup. Here's the complete code:</p>
  
  <pre><code># Shiny App exploring New York City Crime Data between 2006-2016
  # Data Source: https://data.world/data-society/nyc-crime-data
  
  #########################Global Data######################
  
   # Data Reading
   set.seed(123)
   library("shiny")
   library("lubridate") 
   library("plotly")
   nypd&lt;-read.csv("NYPD_Complaint_Data_Historic.csv")
  
   #Data Massaging
   nypd$year&lt;-year(as.Date(nypd$RPT_DT,'%m/%d/%Y'))
   nypd$month&lt;-month(as.Date(nypd$RPT_DT,'%m/%d/%Y'))
   nypd&lt;-nypd[nypd$OFNS_DESC != "",]
   nypd2&lt;-nypd[,c(1,6,8,14,16,17,22,23,25,26)]
  
   ui&lt;-fluidPage(
   titlePanel("New York City Crime Data from 2006-2016"),
   sidebarLayout(
     sidebarPanel(
       sliderInput("year","Year of Crime",min=2006,max=2016,value=2008,step = 1)
     ),
     mainPanel(plotOutput("crimeplot"))
   )
   )
  
  
   server&lt;-function(input,output){
     output$crimeplot&lt;-renderPlot({
  
       nypd_yr_sorted&lt;-nypd2[nypd2$year==input$year,]
       agg_data&lt;-     aggregate(nypd_yr_sorted$CMPLNT_NUM,by=list(nypd_yr_sorted$OFNS_DESC),FUN=functi     on(x)length(unique(x)))
       colnames(agg_data)&lt;-c("Crime","Crime count")
       bar_data&lt;-agg_data[order(agg_data$`Crime count`, decreasing = TRUE),][1:5,]
       plot_ly(bar_data,x=~Crime,y=~`Crime count`,type="bar",color = ~Crime) %&gt;% layout(xaxis= list(showticklabels = FALSE))
     })
  
   }
  
   shinyApp(ui = ui, server = server)
  </code></pre>