问题描述
我不能每次都能正常工作,但是偶尔(足够浪费大量时间进行调试)与downloadHandler()相同的tabBox中的传单地图在下载csv,rmd等后会“出现故障”有人遇到这个问题吗?它发生在已部署的和本地的,但是间歇性的。我添加了一个reprex,它提供了我要传达的内容的框架。但是,它不会出错,或者我无法通过reprex使其出错。任何想法或帮助将不胜感激。谢谢。
library(shinydashboard)
library(shiny)
library(leaflet)
library(tidyverse)
header = dashboardHeader(title = "Hydroclimatic Data")
# * sidebar ----
sidebar = dashboardSidebar(
sidebarMenu(
menuItem(
"Map",tabName = "map",menuSubItem("Map",icon = icon("chart-line"))
)
))
body = dashboardBody(
tabItems(
tabItem(
tabName = "map",fluidRow(
tabBox(width = 12,id = "tab",tabPanel("Map",style = "height:92vh;",leafletoutput("swe_maps")),tabPanel("Summary Stats",dataTableOutput("stats"),selectInput("variable","choose a variable",choices = c(unique(names(mtcars)))),downloadButton(outputId = "downLoadFilter",label = "Download Filtered Data")))
))))
# UI ----------------------------------------------------------------------
ui <- dashboardPage(header = header,sidebar = sidebar,body = body)
# Server ------------------------------------------------------------------
server <- function(input,output,session) {
output$swe_maps <- renderLeaflet({
leaflet() %>% addTiles() %>%
addMouseCoordinates(epsg = "epsg:4326",proj4string = "+proj=utm +zone=32 +ellps=wgs84 +datum=wgs84 +units=m +no_defs") %>%
setView(lat = 48.91167,lng = -114.90246,zoom = 10)
})
mtcars_stat <- reactive({mtcars %>% select(input$variable) %>% summary()})
output$stats = renderDataTable({mtcars_stat() %>% datatable(filter = list(position = 'top')) })
output$downLoadFilter <- downloadHandler(
filename = function() {
paste('filtered_data_',Sys.Date(),'.csv',sep = '')
},content = function(file){
write.csv(mtcars,file)
}
)
}
##### RUN APPLICATION #####
shinyApp(ui = ui,server = server)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)