I'm having trouble with R:Shiny and the observeEvent function

I'm building a shiny app and having trouble with my observeEvent function. Unfortunately, it is supposed to work by slider input for dates. The app runs but when I change the date on the slider the same data keeps popping up over and over again. I believe its only the first couple of rows that are showing over and over again.

this is my full code:

ui <-  bootstrapPage(
  tags$style(type = "text/css", "#map {height: calc(100vh - 80px) !important;}","html, body {width:100%;height:100%}"),
  leafletOutput("map"),
  absolutePanel(top = 10, right = 10,
                sliderInput("dateRange",
                             "Dates:",
                             min = as.Date("2020-01-01","%Y-%m-%d"),
                             max = as.Date("2020-12-01","%Y-%m-%d"),
                             value=as.Date("2020-12-01"),
                             timeFormat="%Y-%m-%d")
                            
        
  )
)


server <- function(input, output) {
  
  result_data$Change1<- cut(result_data$Change, 
                          c(-1,0,1,2,3,4), include.lowest = T,
                          labels = c('increasing', 'decreasing', 'undetectable','no data','test'))
  
  
  beatCol <- colorFactor(palette = 'RdYlGn', result_data$Change1)
  
  


  map=leaflet() %>%
      addProviderTiles(providers$Esri.WorldStreetMap) %>%
      setView(lat = 47.2529, lng = -122.4443, zoom = 10) %>%
      
  #overlay groups
      addLayersControl(
          overlayGroups = c("Basins","Testing sites", "WWTP"),
          position = c("bottomright"),
          options = layersControlOptions(collapsed = FALSE))
  
 
  observeEvent(input$dateRange,
               {
                 leafletProxy("map") %>% 
                   clearMarkers()%>%
                   addCircleMarkers(data = result_data, unique(result_data$Change), 
                                    lat = as.numeric(result_data$Latitude), 
                                    lng = as.numeric(result_data$Longitude), 
                                    weight = 1, 
                                    radius = 10,
                                    fillOpacity = 0.1, 
                                    color = ~beatCol(Change1),
                                    label = ~ as.character(Site),
                                    popup = ~ as.character(Site),
                                    
                                    )
  
               }
               
  )
  
  output$map <- renderLeaflet({

    map
    
  })
  
}

shinyApp(ui, server)

I've tried to fix it by doing this instead with the observeEvent function.

 rv <- reactiveValues(
     filteredData =result_data,
     ids = unique(result_data$Change)
   )

   observeEvent(input$dateRange,
                {
                  leafletProxy("map") %>%
                    clearMarkers()%>%
                    addCircleMarkers(data = subset(rv$filteredData, Change == rv$ids),
                                     lat = as.numeric(rv$filteredData$Latitude),
                                     lng = as.numeric(rv$filteredData$Longitude),
                                     weight = 1,
                                     radius = 10,
                                     fillOpacity = 0.1,
                                     color = ~beatCol(Change1),
                                     label = ~ as.character(Site),
                                     popup = ~ as.character(Site),

                                  )
               }
  )

I still get the same issue.

A snippet of the dataset that observeEvent is pulling from:

Site	             Change       Date 		Latitude	Longitude
Basin C04 (MH-6761957)	1	2020-05-22	47.23513	-122.40374
Basin C04 (MH-6761957)	2	2020-05-29	47.23513	-122.40374
Basin C04 (MH-6761957)	2	2020-06-05	47.23513	-122.40374
Basin C04 (MH-6761957)	1	2020-06-12	47.23513	-122.40374
Basin C04 (MH-6761957)	2	2020-06-19	47.23513	-122.40374
Basin C04 (MH-6761957)	2	2020-06-25	47.23513	-122.40374
Basin C04 (MH-6761957)	1	2020-07-02	47.23513	-122.40374
Basin C04 (MH-6761957)	2	2020-07-09	47.23513	-122.40374
Basin C04 (MH-6761957)	2	2020-07-16	47.23513	-122.40374
Basin C04 (MH-6761957)	1	2020-07-23	47.23513	-122.40374
Basin C04 (MH-6761957)	1	2020-07-30	47.23513	-122.40374
Basin C09 (MH-6754884) alt site	0	2020-05-15	47.22362	-122.442
Basin C09 (MH-6754884) alt site	0	2020-05-22	47.22362	-122.442
Basin C09 (MH-6754884) alt site	0	2020-05-29	47.22362	-122.442
Basin C09 (MH-6754884) alt site	0	2020-06-05	47.22362	-122.442
Basin C09 (MH-6754884) alt site	1	2020-06-12	47.22362	-122.442
Basin C09 (MH-6754884) alt site	2	2020-06-19	47.22362	-122.442
Basin C09 (MH-6754884) alt site	0	2020-06-25	47.22362	-122.442
Basin C09 (MH-6754884) alt site	0	2020-07-02	47.22362	-122.442
Basin C09 (MH-6754884) alt site	0	2020-07-09	47.22362	-122.442
Basin C09 (MH-6754884) alt site	0	2020-07-16	47.22362	-122.442
Basin C09 (MH-6754884) alt site	0	2020-07-23	47.22362	-122.442

I am just getting the first date for each site and then it never changes. I want to be able select a date and the circle marker would change for that site according to the change value. For example, if I select 2020-06-05 then the circle marker would change to the color that is associated with 0 and if I slide it to 2020-06-12 then it should change to the color associated with 1. I'm new to R studio and this is my first time using shiny app so please excuse me if this is a no brainer.

Hello @VS_09,

Welcome to the forum! Happy to help you if you can add some data along with your code above so I can run it locally and see the behaviour. I suggest using something like datapasta (See here: https://cran.r-project.org/web/packages/datapasta/vignettes/how-to-datapasta.html) (Have a look here too on good code to share: FAQ: How to do a minimal reproducible example ( reprex ) for beginners)

@GreyMerchant Sorry, first time posting to RStudio community

do you want it like this?

tibble::tribble(
                                        ~Site, ~Change,        ~Date,            ~Latitude, ~Longitude,
        "Pierce County (Chambers Creek WWTP)",       2, "2020-04-29", "47.240789999999997", -122.43955,
  "Basin W01 (MH-6759100) ML-002B (Metering)",       0, "2020-05-06", "47.246549999999999", -122.55069,
        "Pierce County (Chambers Creek WWTP)",       1, "2020-05-06", "47.240789999999997", -122.43955,
  "Basin W01 (MH-6759100) ML-002B (Metering)",       1, "2020-05-12", "47.246549999999999", -122.55069,
            "City of Tacoma (North End WWTP)",       2, "2020-05-12",           "47.28595",   -122.489,
        "Pierce County (Chambers Creek WWTP)",       2, "2020-05-13", "47.240789999999997", -122.43955
  )

or like this

                                    Site      Change  Date            Latitude          Longitude
1         Pierce County (Chambers Creek WWTP)      2 2020-04-29  47.240789999999997 -122.4395
2   Basin W01 (MH-6759100) ML-002B (Metering)      0 2020-05-06  47.246549999999999 -122.5507
3         Pierce County (Chambers Creek WWTP)      1 2020-05-06  47.240789999999997 -122.4395
4   Basin W01 (MH-6759100) ML-002B (Metering)      1 2020-05-12  47.246549999999999 -122.5507
5             City of Tacoma (North End WWTP)      2 2020-05-12            47.28595 -122.4890
6         Pierce County (Chambers Creek WWTP)      2 2020-05-13  47.240789999999997 -122.4395
7             Basin C09 (MH-6754884) alt site      0 2020-05-15  47.223619999999997 -122.4420
8                      Basin C04 (MH-6761957)      1 2020-05-22  47.235129999999998 -122.4037
9             Basin C09 (MH-6754884) alt site      0 2020-05-22  47.223619999999997 -122.4420
10                     Basin N03 (MH-6779312)      2 2020-05-22 47.25901 -122.49032        NA
11                     Basin N04 (MH-6770623)      2 2020-05-22  47.257930000000002 -122.4747
12  Basin W01 (MH-6759100) ML-002B (Metering)      2 2020-05-22  47.246549999999999 -122.5507
13            City of Tacoma (North End WWTP)      1 2020-05-22            47.28595 -122.4890
14                     Basin C04 (MH-6761957)      2 2020-05-29  47.235129999999998 -122.4037
15            Basin C09 (MH-6754884) alt site      0 2020-05-29  47.223619999999997 -122.4420
16                     Basin N03 (MH-6779312)      0 2020-05-29 47.25901 -122.49032        NA
17                     Basin N04 (MH-6770623)      0 2020-05-29  47.257930000000002 -122.4747
18  Basin W01 (MH-6759100) ML-002B (Metering)      0 2020-05-29  47.246549999999999 -122.5507
19                        City of Sumner WWTP      2 2020-05-29            47.19961 -122.2542
20            City of Tacoma (North End WWTP)      1 2020-05-29            47.28595 -122.4890
21                     Basin C04 (MH-6761957)      2 2020-06-05  47.235129999999998 -122.4037
22            Basin C09 (MH-6754884) alt site      0 2020-06-05  47.223619999999997 -122.4420
23                     Basin N03 (MH-6779312)      1 2020-06-05 47.25901 -122.49032        NA
24                     Basin N04 (MH-6770623)      0 2020-06-05  47.257930000000002 -122.4747
25  Basin W01 (MH-6759100) ML-002B (Metering)      0 2020-06-05  47.246549999999999 -122.5507
26                        City of Sumner WWTP      2 2020-06-05            47.19961 -122.2542
27            City of Tacoma (North End WWTP)      2 2020-06-05            47.28595 -122.4890
28                     Basin C04 (MH-6761957)      1 2020-06-12  47.235129999999998 -122.4037
29            Basin C09 (MH-6754884) alt site      1 2020-06-12  47.223619999999997 -122.4420
30                     Basin N03 (MH-6779312)      2 2020-06-12 47.25901 -122.49032        NA
31                     Basin N04 (MH-6770623)      1 2020-06-12  47.257930000000002 -122.4747
32  Basin W01 (MH-6759100) ML-002B (Metering)      0 2020-06-12  47.246549999999999 -122.5507
33                        City of Sumner WWTP      1 2020-06-12            47.19961 -122.2542
34            City of Tacoma (North End WWTP)      1 2020-06-12            47.28595 -122.4890
35                     Basin C04 (MH-6761957)      2 2020-06-19  47.235129999999998 -122.4037
36            Basin C09 (MH-6754884) alt site      2 2020-06-19  47.223619999999997 -122.4420
37                     Basin N03 (MH-6779312)      0 2020-06-19 47.25901 -122.49032        NA
38                     Basin N04 (MH-6770623)      2 2020-06-19  47.257930000000002 -122.4747
39  Basin W01 (MH-6759100) ML-002B (Metering)      0 2020-06-19  47.246549999999999 -122.5507
40                        City of Sumner WWTP      1 2020-06-19            47.19961 -122.2542
41            City of Tacoma (North End WWTP)      2 2020-06-19            47.28595 -122.4890
42                     Basin C04 (MH-6761957)      2 2020-06-25  47.235129999999998 -122.4037
43            Basin C09 (MH-6754884) alt site      0 2020-06-25  47.223619999999997 -122.4420

some of these values are showing up as null but I am not sure why that's happening

Currently all you do with input$dateRange is observed observeEvent it, i.e. trigger an expression when the input changes. But you don't do anything with the content of the input$dateRange.
I suppose you would expect to use it to adjust some data somewhere, to make something different happen based on it.
Something to think about.