Shiny 渲染器中的滑块不工作
我有一个闪亮的应用程序:Shiny 渲染器中的滑块不工作,shiny,Shiny,我有一个闪亮的应用程序: 从一张有一些要点的传单开始 允许用户使用fileInput加载CSV 使用Proxy在地图上打印CSV 动态添加滑块以过滤新CSV中的值 我的问题是滑块对贴图没有任何影响。它显示得很好,但当我移动它时,观察和观察都没有效果 我的代码的相关部分是 # Create a new map with the data uploaded observe({ if (is.null(newdata())) return(NULL) # Update th
- 从一张有一些要点的传单开始
- 允许用户使用fileInput加载CSV
- 使用Proxy在地图上打印CSV
- 动态添加滑块以过滤新CSV中的值
# Create a new map with the data uploaded
observe({
if (is.null(newdata())) return(NULL)
# Update the map
leafletProxy("map", data = newdata()) %>%
clearMarkers() %>%
addCircles(newdata()$Y,
newdata()$X,
color = "red")
# Add a slider
datecol <- newdata()$Date
output$setSlider <- renderUI({
if (is.null(newdata())) return(NULL)
sliderInput("range", "Dates",
min = as.Date(min(datecol)),
max = as.Date(max(datecol)),#,"%Y-%m-%d"
value = c(as.Date(min(datecol)),as.Date(max(datecol))),
timeFormat="%Y-%m-%d")
})
})
# Filter the data
dataloc <- reactive({
print(input$range)
filteredData <- newdata()
if(!is.null(input$range)){
filteredData <- filteredData %>%
filter(filteredData$Date >= input$range[1],
filteredData$Date <= input$range[2])
}
return(filteredData)
})
observeEvent(input$range,{
filterloc <- dataloc()
print("event")
if (is.null(newdata())) return(NULL)
if (!is.null(dataloc())) return(print(dataloc()))
# Update the map
leafletProxy("map", data = dataloc()) %>%
clearMarkers() %>%
addCircles(dataloc()$Y,
dataloc()$X,
color = "red")
}
)
#使用上载的数据创建新地图
观察({
if(is.null(newdata())返回(null)
#更新地图
传单代理(“映射”,data=newdata())%>%
clearMarkers()%>%
添加圆(newdata()$Y,
newdata()$X,
color=“红色”)
#添加一个滑块
datecol我实际上有一个“提交按钮”,它阻止了其他事件的发生。问题解决了