0

所以我一直在创建一个在我的机器上正常运行的 Shiny 应用程序。但是,当我尝试将其发布到 shinyapp.io 时,它给了我错误:

错误:发生错误。检查您的日志或联系应用作者进行澄清。

我使用令牌并尝试使用示例应用程序进行发布,所有这些都有效,因此我剥离了整个应用程序以查看问题所在,并发现 read_excel 函数使我无法发布。所以这是我能够发布的简化版本。在下面查找导致其无法发布的原因。

library(shiny)
library(leaflet)
library(dplyr)
library(readxl)

ui <- fluidPage(
  bootstrapPage(
    tags$style(type = "text/css", "html, body {width:100%;height:100%}"),
    leafletOutput("map", width = "100%", height = 800),
    absolutePanel(top = 10, right = 10, 
                  checkboxGroupInput("Containers", "Type containers", 
                                     choices = c("Restafval ondergronds" = 1, "Papier ondergronds" = 2, "Glas ondergronds" = 3, 
                                             "Rest halfverdiept" = 4, "Papier halfverdiept" = 5, "Glas halfverdiept" = 6), selected= c(1,4)),
              radioButtons("Grenzen", "Grenzen gebieden weergeven", 
                           choices = c("Stadsniveau" = 1, "Wijkniveau" = 2, "Buurtniveau" = 3), selected= 1),
              radioButtons("Radii", "Straal vanaf containers", 
                           choices = c("Geen" = 0, "100 meter" = 1, "200 meter" = 2, "300 meter" = 3, "400 meter" = 4, "500 meter" = 5), selected= 0)))
)


server <- function(input, output) {
  output$map <- renderLeaflet({
    leaflet() %>% 
      addProviderTiles("Stamen.Terrain") %>% 
      setView(lng = 4.344572,lat = 51.915739 ,zoom = 12) %>%
      addLegend("bottomright", 
            colors= c("blue", "deepskyblue", "green", "chartreuse", "red", "orange"),
            labels= c("Restafval ondergronds", "Restafval halfverdiept", "Papier ondergronds", "Papier halfverdiept", "Glas ondergronds", "Glas halfverdiept"), 
            title = "Leganda containers per soort:", opacity = 0.5)
  })
}


shinyApp(ui = ui, server = server)

但是,当使用以下方式导入数据时:

library(shiny)
library(leaflet)
library(dplyr)
library(readxl)

containers_gathered <- read_excel("containers_gathered.xlsx")

ui <- fluidPage(   etc...

(甚至在服务器部分添加层之前)。它使我无法发布应用程序。数据集在项目文件夹中,那么我在这里做错了什么?

正如我所说,这一切都在本地正常运行。也有一个空的环境。希望有人能够提供帮助。

当使用 rsconnect::showLogs() 它说:

1: local
Error : An error has occurred. Check your logs or contact the app author for 
clarification.
3: eval
2: eval.parent
4

1 回答 1

2

我找到了解决方案。与其将数据保存在保存应用程序的项目目录文件夹中,不如将其保存在保存项目的子文件夹中。所以:

containers_gathered <- read_excel("Data/containers_gathered.xlsx") 

代替:

containers_gathered <- read_excel("containers_gathered.xlsx")
于 2017-10-12T07:40:08.070 回答