所以我一直在创建一个在我的机器上正常运行的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
答案 0 :(得分:2)
我找到了解决方案。而不是将数据保存在保存应用程序的项目目录文件夹中,它必须位于保存项目的子文件夹中。 所以:
containers_gathered <- read_excel("Data/containers_gathered.xlsx")
而不是:
containers_gathered <- read_excel("containers_gathered.xlsx")