全部都在闪亮的选择输入中

问题描述 投票:0回答:1

我有一张闪亮的地图,我需要在其中过滤掉土著人和非土著人。但我还需要过滤掉所有土著和非土著人民。我正在使用选择输入。

enter image description here

filtered <- reactive({
      filter(places_df,INDIGENA == input$INDIGENA)

if(input$INDIGENA =='ALL')
places_df

    })

    output$MapPlot1 <- renderLeaflet({
      
        leaflet(data =  filtered())%>% 
        setView(-51.127166, -4.299999, 10)%>%  
        addTiles()%>%
        addMarkers(popup = paste0(places_df$ID.GRUPO.FAMILIAR, "</br>", places_df$LOCALIDADES))
    
    })
    
    
    observe(
      leafletProxy("MapPlot1", data = filtered ())%>%  
        clearMarkers()%>%  
        addMarkers(popup = paste0(places_df$ID.GRUPO.FAMILIAR, "</br>", places_df$LOCALIDADES))
      )
    
r shiny r-leaflet
1个回答
0
投票

与函数类似,反应导体返回其主体的最后一条语句。如果

input$INDIGENA
不等于
'ALL'
,则语句

  if(input$INDIGENA == 'ALL'){
    places_df
  }

评估为

NULL

尝试:

filtered <- reactive({
  if(input$INDIGENA == 'ALL'){
    places_df
  }else{
    filter(places_df,INDIGENA == input$INDIGENA)
  }
})
© www.soinside.com 2019 - 2024. All rights reserved.