I am creating a R Shiny application using a bike sharing data set. I would like to create circle markers that show the number of incoming rides per station for a specific user input date (date()
).
First, I am calculating the number of trips per station in a reactive function using pipes and summarize()
. In the circle markers I would then like to use the calculated n_trips
as the label when you hover over a circle. However, even though I can take all non-calculated values as a circle label, using n_trips
does return any label at all. How can I show the calculated value as my label for the circle markers?
filtered <- reactive ({df.trip %>%
filter(format(df.trip$starttime,"%Y-%m-%d") == date()) %>%
group_by(from_station_id) %>%
summarize(n_trips = n()) %>%
left_join(df.station, by = c("from_station_id" = "station_id")})``
output$secondExample <- renderLeaflet({
leaflet(filtered()) %>%
addTiles(group="OSM") %>%#OSM is default tile providor
addProviderTiles(providers$Stamen.TonerLite) %>%
setView(lng=-122.335167,
lat=47.619113,
zoom=12.46)%>%
addCircleMarkers(lng = ~long, lat = ~lat, weight = 1,label=~htmlEscape(n_trips), radius = ~n_trips)})``