title: Plotting subsetted data in R Shiny with DateRangeInput
body: <p>I am trying to subset a data set using a few input parameters and then plot the output. I am able to plot various stats over time for various teams, but I am unable to figure out how to subset my data for an input date range. Attached is my server and ui.</p>
  
  <p>Server:</p>
  
  <pre><code>library(shiny)
  
  season = read.csv("2016_Season.csv")
  season$date = as.POSIXct(season$date)
  
  function(input, output) {
  
     adjust &lt;- function() {
  
       data = season
  
       #data = data[data$date &gt;= input$dates[1],]
       #data = data[data$date &lt;= input$dates[2],]
  
       if (input$Team != "All"){                
        data &lt;- data[data$Team == input$Team,] 
       }
  
       data = data[,c('date',input$Stat)]
  
        }
  
     output$distPlot &lt;- renderPlot({
  
       plot(adjust())
     })
  }
  </code></pre>
  
  <p>UI:</p>
  
  <pre><code>library(shiny)
  
  season = read.csv("2016_Season.csv")
  season$date = as.POSIXct(season$date)
  
  shinyUI(fluidPage(
  
    titlePanel("Time Plot"),
  
    sidebarPanel(
  
      fluidRow(
        div(class="span4",
            selectInput('Team',
                        'Team:',
                        c('All',unique(as.character(season$Team)))))
       ),
  
      fluidRow(
        div(class="span4",                                            
            selectInput("Stat",                                      
                        "Stat:",
                        c('PTS','TRB','AST')))
       ),
  
      dateRangeInput("dates", 
                     "Date range",
                     start = min(season$date),
                     end = max(season$date))
    ),
  
    mainPanel(
      plotOutput("distPlot")                     
    )                                           
  ))
  </code></pre>
  
  <p>The code works fine when the these two lines are commented out in the server, though obviously the date filters dont work:</p>
  
  <pre><code> #data = data[data$date &gt;= input$dates[1],]
   #data = data[data$date &lt;= input$dates[2],]
  </code></pre>
  
  <p>but I remove the comments i get the error 'need finite 'xlim' values' and I am not sure how to fix it.</p>