I am trying to write a simple If Cycle in R Shiny but I am founding some issues. I want to create a variable, in this case m, according to what the user inputs. Here there is the code:
if(input$city=="Enter Text..."){
m<-reactive({leaflet() %>%
addProviderTiles(providers$OpenStreetMap.BlackAndWhite) %>%
addPolylines(data = trips(),
lng = ~V1,
lat = ~V2,weight=1,color="purple") %>%
addCircles(lng = geocode(input$city)$lon, lat = geocode(input$city)$lat, weight = 5,
radius =input$radius, popup = input$city, color="blue",fillOpacity = 0)
})
} else {
m<-reactive({leaflet() %>%
addProviderTiles(providers$OpenStreetMap.BlackAndWhite) %>%
addPolylines(data = trips(),
lng = ~V1,
lat = ~V2,weight=1,color="purple")
})
}
In doing this I get an error that says that I am trying to do something outside a reactive environment, but the variable m is defined as reactive. How can I fix this?
Thanks
Aucun commentaire:
Enregistrer un commentaire