Development of Shiny app for real time traffic monitoring

...Hello, so I'm currently working on the above topic. I have developed the basic ui and a part of the server but I have issues with creating the reactive and observe event. I want my map to show the condition of traffic flow in a selected route and day of the week based on the input of the user.
Below is my code
server <- function(input, output,session) {
updateSelectizeInput(session, "route", choices = m$name, server=TRUE)
selectedDay <- reactive({switch(input$Day,
"Monday"=m$Traffic_Flow,
"Wednesday"=m$Traffic_Flow,
"Friday"=m$Traffic_Flow,
"Saturday"=m$Traffic_Flow)
})
pal <- colorNumeric(palette=c('Red', 'Blue', 'Orange'), domain=m$Traffic_Flow)

output$mymap <- renderLeaflet({
leaflet(m) %>%
addTiles() %>%
setView(lng = 3.29611, lat=6.61085,zoom=11) %>%
addPolygons(data=map,weight=5,col = 'black') %>%
addPolylines(data=m,fillColor=~pal(selectedDay()))
})

observeEvent(input$Day, {
leafletProxy("m", data = selectedDay()) %>%
clearShapes() %>%
addPolylines(data = m, col = "red", weight=2)
})
}

and for the ui
ui <- fluidPage(
actionButton("update", "Update View"),
sidebarLayout(
sidebarPanel(
selectInput("Day", "Day of the week", c("Monday", "Wednesday", "Friday", "Saturday")),
selectInput("time", "Time of the day", c("Morning", "Evening")),
selectizeInput("route", "Route", choices="", multiple=FALSE, options = list(
placeholder = 'Please select a route from below')
)
),
mainPanel(
leafletOutput("mymap",height = 1000)

    )
)

)

I have my csv and shapefiles in my process.R

library(shiny)
library(dplyr)
library(leaflet)
library(rgdal)
library(DT)

map <- readOGR("C:/Users/user/Desktop/LAGOS/Alimosho.shp")
map <- spTransform(map, CRS("+proj=longlat +ellps=GRS80"))
roads <- readOGR("C:/Users/user/Desktop/LAGOS/Major_Roads.shp")
roads <- spTransform(roads, CRS("+proj=longlat +ellps=GRS80"))
count <- read.csv("C:/Users/user/Desktop/LAGOS/TrafficCount.csv")
Tcount <- traffic[c(1:24),]
saveRDS(count, "C:/Users/user/Desktop/LAGOS/count.rds")
traffic <- read.csv("C:/Users/user/Desktop/LAGOS/traffic.csv")
m <- merge(roads, traffic, by='name')

This is what my map looks like after all that
image

Where am I missing it? What is missing?

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.