title: Error in running Shiny app from specified dates. Warning: Error in : Result must have length 121728, not 0
body: <p>I am trying to create a Shiny app which takes a dataset (shiny_clean) and creates a ggplot line plot which shows the model power predictions vs time on the x axis. Here is my data</p>
  
  <pre><code>Timestamp Turbine_ID Grd_Prod_Pwr_Avg Amb_WindSpeed_Max Amb_WindSpeed_Min Amb_WindSpeed_Avg Amb_WindSpeed_Std
  1 2017-06-02 00:00:00        T07            891.6              14.2               2.8               7.8               1.4
  2 2017-06-02 00:00:00        T06           1338.1              17.2               3.8               9.3               1.5
  3 2017-06-02 00:00:00        T11            677.6              16.3               3.5               7.5               1.2
  4 2017-06-02 00:00:00        T01            656.1              17.5               1.2               7.2               1.7
  5 2017-06-02 00:10:00        T01            759.6              16.4               2.1               7.6               1.4
  6 2017-06-02 00:10:00        T06           1145.0              13.9               3.3               8.6               1.3
    Amb_WindDir_Abs_Avg Nac_Direction_Avg Min_Windspeed1 Max_Windspeed1 Avg_Windspeed1 Var_Windspeed1 Min_Windspeed2
  1               106.2              93.6            7.1           12.0            9.7           0.63            6.8
  2                84.3              98.4            7.1           12.0            9.7           0.63            6.8
  3                90.5              99.6            7.1           12.0            9.7           0.63            6.8
  4               106.8             116.2            7.1           12.0            9.7           0.63            6.8
  5                98.8             116.2            7.9           12.1           10.1           0.73            7.4
  6                96.2              98.4            7.9           12.1           10.1           0.73            7.4
    Max_Windspeed2 Avg_Windspeed2 Var_Windspeed2 Min_AmbientTemp Max_AmbientTemp Avg_AmbientTemp Min_Pressure Max_Pressure
  1           10.6            8.6           0.40              21              22              22         1008         1009
  2           10.6            8.6           0.40              21              22              22         1008         1009
  3           10.6            8.6           0.40              21              22              22         1008         1009
  4           10.6            8.6           0.40              21              22              22         1008         1009
  5           10.5            8.9           0.47              21              22              22         1008         1009
  6           10.5            8.9           0.47              21              22              22         1008         1009
    Avg_Pressure Min_Humidity Max_Humidity Avg_Humidity   results     model
  1         1009           68           69           68  788.8035 WGT_RF_NN
  2         1009           68           69           68 1283.3277 WGT_RF_NN
  3         1009           68           69           68  712.6971 WGT_RF_NN
  4         1009           68           69           68  651.6901 WGT_RF_NN
  5         1009           68           69           68  734.4558 WGT_RF_NN
  6         1009           68           69           68  940.1862 WGT_RF_NN
  </code></pre>
  
  <pre><code>structure(list(Timestamp = structure(c(1496361600, 1496361600, 
  1496361600, 1496361600, 1496362200, 1496362200), class = c("POSIXct", 
  "POSIXt"), tzone = "UTC"), Turbine_ID = structure(c(3L, 2L, 4L, 
  1L, 1L, 2L), .Label = c("T01", "T06", "T07", "T11"), class = "factor"), 
      Grd_Prod_Pwr_Avg = c(891.6, 1338.1, 677.6, 656.1, 759.6, 
      1145), Amb_WindSpeed_Max = c(14.2, 17.2, 16.3, 17.5, 16.4, 
      13.9), Amb_WindSpeed_Min = c(2.8, 3.8, 3.5, 1.2, 2.1, 3.3
      ), Amb_WindSpeed_Avg = c(7.8, 9.3, 7.5, 7.2, 7.6, 8.6), Amb_WindSpeed_Std = c(1.4, 
      1.5, 1.2, 1.7, 1.4, 1.3), Amb_WindDir_Abs_Avg = c(106.2, 
      84.3, 90.5, 106.8, 98.8, 96.2), Nac_Direction_Avg = c(93.6, 
      98.4, 99.6, 116.2, 116.2, 98.4), Min_Windspeed1 = c(7.1, 
      7.1, 7.1, 7.1, 7.9, 7.9), Max_Windspeed1 = c(12, 12, 12, 
      12, 12.1, 12.1), Avg_Windspeed1 = c(9.7, 9.7, 9.7, 9.7, 10.1, 
      10.1), Var_Windspeed1 = c(0.63, 0.63, 0.63, 0.63, 0.73, 0.73
      ), Min_Windspeed2 = c(6.8, 6.8, 6.8, 6.8, 7.4, 7.4), Max_Windspeed2 = c(10.6, 
      10.6, 10.6, 10.6, 10.5, 10.5), Avg_Windspeed2 = c(8.6, 8.6, 
      8.6, 8.6, 8.9, 8.9), Var_Windspeed2 = c(0.4, 0.4, 0.4, 0.4, 
      0.47, 0.47), Min_AmbientTemp = c(21L, 21L, 21L, 21L, 21L, 
      21L), Max_AmbientTemp = c(22L, 22L, 22L, 22L, 22L, 22L), 
      Avg_AmbientTemp = c(22L, 22L, 22L, 22L, 22L, 22L), Min_Pressure = c(1008L, 
      1008L, 1008L, 1008L, 1008L, 1008L), Max_Pressure = c(1009L, 
      1009L, 1009L, 1009L, 1009L, 1009L), Avg_Pressure = c(1009L, 
      1009L, 1009L, 1009L, 1009L, 1009L), Min_Humidity = c(68L, 
      68L, 68L, 68L, 68L, 68L), Max_Humidity = c(69L, 69L, 69L, 
      69L, 69L, 69L), Avg_Humidity = c(68L, 68L, 68L, 68L, 68L, 
      68L), results = c(788.803513248849, 1283.32772621174, 712.697125017365, 
      651.690136285811, 734.455829490413, 940.186175814292), model = structure(c(1L, 
      1L, 1L, 1L, 1L, 1L), .Label = "WGT_RF_NN", class = "factor")), row.names = c(NA, 
  6L), class = "data.frame")
  </code></pre>
  
  <p>My ui works fine. But when I run the app I get a warning Error in : Result must have length 121728, not 0. I suspect this is something to do with filtering but I can't work it out. This is what I see when I run the app.</p>
  
  <p><a href="https://i.stack.imgur.com/CaLjA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CaLjA.png" alt="enter image description here"></a></p>
  
  <p>Here is my code:</p>
  
  <pre><code>library(shiny)
  library(ggplot2)
  library(tidyverse)
  library(lubridate)
  
  shiny_clean &lt;- read.csv("shiny_clean.csv", stringsAsFactors = FALSE)
  shiny_clean &lt;- filter(shiny_clean, shiny_clean$Timestamp &gt; as.Date("2017-06-01"))
  
  ui &lt;- fluidPage(
    titlePanel("Machine learning ensemble model to predict wind farm power output"),
      sidebarPanel(
        dateInput("dateInput", "Date", min = min(shiny_clean$Timestamp), max =max(shiny_clean$Timestamp), value = min(shiny_clean$Timestamp)),
        radioButtons("typeInput", "Turbine",
                     choices = c("T01", "T06", "T07", "T11"),
                     selected = "T01"),
        uiOutput("modelOutput")
      ),
    mainPanel(
      plotOutput("coolplot"),
      br(), br(),
      tableOutput("results")
    )
    )
  
  server &lt;- function(input, output) {
  
    output$modelOutput &lt;- renderUI({
      selectInput("modelInput", "Model",
                  sort(unique(shiny_clean$model)),
                  selected = "WGT_RF_NN")
    })  
  
  filtered &lt;- reactive({
    if (is.null(input$modelInput)) {
      return(NULL)
    }    
  
    shiny_clean %&gt;%
      filter(Timestamp == input$dateInput,
             Turbine_ID == input$typeInput,
             model == input$modelinput
      )
  })
  
  output$coolplot &lt;- renderPlot({
    if (is.null(filtered())) {
      return()
    }
    ggplot()+
      geom_line(data = filtered, aes(x=Timestamp, y=results))
  })
  
  output$results &lt;- renderTable({
    filtered()
  })
  }
  
  shinyApp(ui = ui, server = server)
  </code></pre>