具有空间折线数据框的R闪亮,反应灵敏的闪亮应用

时间:2019-09-17 16:43:39

标签: shiny shiny-reactivity

我一直在可视化某些路线的交通流,具体取决于一周中的几天。我的csv文件包含一周中不同日期的路线名称和流量。我也有路线的shapefile。我尝试遵循此示例,但无济于事……无反应enter link description here

对不起,但是我的代码看起来像这样。我是初学者,请忍受我

ui <- fluidPage(    
sidebarLayout(    
    sidebarPanel(    
      selectInput("routeInput", "Route",    
                  choices = c("Select Route", "Meiran Road",    
"Command Secondary School Road",    
"Ipaja Road",    
"Lagos-Abeokuta Expressway",    
"Governor's Road",    
"Alimosho Road",    
"Lasu-Isheri Road",    
"Idimu - Ikotun Road",    
"Egbeda-Idimu Road",    
"21 -Okunola Road",    
"Ekoro Agbelekale",    
"Church Road",    
"Osenatu Ilo St.",    
"Old Ota Road",    
"Post Office Road",    
"Otta Expressway",    
"Ayetoro Road",    
"Ilo Awela Road",    
"A.I.T Road",    
"Nureni Yusuf Road",    
"Akesan Road",    
"Ijagemo Road",    
"Adetiba Street",    
"Ikotun - Ejigbo Road",    
"Abaranje Road",    
"Ayobo Road"),    
selected = "Select Route"),
  checkboxGroupInput("dayInput","Day", choices = Days, selected =as.character(Days)),
actionLink("selectall", "Select All")
        ),
    mainPanel(
        leafletOutput("mymap",height = 500)

    )
)
)


    SERVER
server <- function(input, output,session) {

  selected <- reactive({
 Flow <- filter(Flow,
            day == input$dayInput)
 Flow
  })
  output$mymap <- renderLeaflet({
        leaflet()  %>% 
        addTiles() %>% 
  addProviderTiles("CartoDB.DarkMatter", layerId = "basetile",options = providerTileOptions(minZoom = 6)) %>%
        setView(lng = 3.29611, lat=6.61085,zoom=11) %>%
  addPolylines(data=m, weight = 2, opacity = 0.5, color ="#03F", fillColor = "red")

  })
  observe({
if(!is.null(input$dayInput)){
  roads <- left_join(roads, selected(), by="name")
  leafletProxy("mymap", data=roads) %>%
    addTiles() %>%
  clearShapes() %>%
  addPolylines(weight = 2, opacity = 0.5, color = "#777777")
}
  })

}     进程     图书馆(闪亮)     图书馆(dplyr) 图书馆(传单) 图书馆(rgdal) 库(DT)

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/Flow.csv")
Days <- list("Monday", "Wednesday", "Friday", "Saturday")

0 个答案:

没有答案