title: Subset df based on Shiny input + lat and lng radius
body: <p>I'm trying to build a shiny app that will render a geom_line plot with two different time series, one of them is price of my apartments to choose from a SelectInput, the second line in the plot should be the price of apartments of which lat and lng should be between new_latitude and new_longitude from the first input, aggregated by day so that the end result is just one continuous line. In this plot the x is day of the year and the y is average price. The input should only be my apartments</p>
  
  <p>This is my df head()</p>
  
  <pre><code>df&lt;-structure(list(unitcode = c("23986", "23986", "23986", "23986", 
  "23986", "23986"), lat = c(45.44991, 45.44991, 45.44991, 45.44991, 
  45.44991, 45.44991), lng = c(9.17597, 9.17597, 9.17597, 9.17597, 
  9.17597, 9.17597), bedrooms = c(1L, 1L, 1L, 1L, 1L, 1L), maxoccupancytotal = c(4L, 
  4L, 4L, 4L, 4L, 4L), day_of_year = c(55L, 106L, 107L, 108L, 109L, 
  110L), avg_price = c(190L, 187L, 187L, 187L, 187L, 187L), past_future = c("past", 
  "past", "past", "past", "future", "future"), new_latitude = c(49.9415829000532, 
  49.9415829000532, 49.9415829000532, 49.9415829000532, 49.9415829000532, 
  49.9415829000532), new_longitude = c(15.578627910762, 15.578627910762, 
  15.578627910762, 15.578627910762, 15.578627910762, 15.578627910762
  )), row.names = c(NA, 6L), class = "data.frame")
  
  </code></pre>
  
  <p>This is what I got so far, I'm missing the whole part of summarising and filtering based on lat and lng because quite frankly I'm relatively new to R and totally new to Shiny and don't even know where to start</p>
  
  <pre><code>ui &lt;- fluidPage(theme = shinytheme("darkly"),
  
  #Header
  h1("Cohort Health Check", align = "center"),
  
  selectInput(
      inputId = "unitcode",
      label = "Select unit",
      choices = unique(df$unitcode),
      selected = "23986"
    ),
  
  
  plotlyOutput("plot", height = "650px")
  )
  
  server &lt;- function(input, output, session) {
  
    output$plot &lt;- renderPlotly({
      df%&gt;%
        filter(unitcode == input$unitcode) %&gt;%
        ggplot(aes(day_of_year, avg_price)) +
        geom_line(aes(color = past_future))+ 
        scale_y_continuous(breaks = seq(0,2000,25),labels = dollar)+
        scale_x_continuous(breaks = seq(0,365,7))+
        scale_color_manual(values=c( "black", "red"))+
        theme_economist()
    })
  
  }
  
  shinyApp(ui, server)
  </code></pre>