Reputation: 31
So I have been creating a Shiny app which runs properly on my machine. However when I try to publish it to shinyapp.io it gives me the error:
ERROR: An error has occurred. Check your logs or contact the app author for clarification.
I used the token and tried to publish with an example app and all of that works, so I have stripped the whole app down to see where the problem lays, and found that the read_excel function makes me unable to publish. So here is a simplified version of that I am able to publish. Find below what makes it unable to publish.
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)
However, when importing data with:
library(shiny)
library(leaflet)
library(dplyr)
library(readxl)
containers_gathered <- read_excel("containers_gathered.xlsx")
ui <- fluidPage( etc...
(even before adding layers in the server part). It keeps me from publishing the app. The dataset is in the project folder, so what do I do wrong here?
As I said, it all runs properly local. Also with an empty environment. Hope someone is able to assist.
When using rsconnect::showLogs() it says:
1: local
Error : An error has occurred. Check your logs or contact the app author for
clarification.
3: eval
2: eval.parent
Upvotes: 0
Views: 209
Reputation: 31
I found the solution. Rather then saving the data IN the project directory folder where the app is saved, it had to be in a subfolder where the project is saved. So:
containers_gathered <- read_excel("Data/containers_gathered.xlsx")
instead of:
containers_gathered <- read_excel("containers_gathered.xlsx")
Upvotes: 2