I have been trying to publish a shiny app for multiple times. It works fine locally, but when publishing to shinyapps.io it keeps showing the "An Error Has Occurred. The Application Failed to Start." However the logs does not display any errors or exit code.
My code below:
#prepare packages
library(shiny)
library(rsconnect)
library(ggplot2)
library(dplyr)
library(readxl)
library(tidyr)
library(lubridate)
#prepare data
df <- read_excel("Data/ERCOT Generation by Fuel data_Jan2009 to Mar2022.xlsx")
df_datetime <- df %>%
mutate(timestamp = substring(DateTime,1,5)) %>%
mutate(Date = as.Date(Date)) %>%
gather(key = "Fuel", value = "Gen_MWh",
Nuclear, Coal, Hydro, `All Other`, Gas, `Gas CC`, Wind, Solar) %>%
mutate(time_only = hm(timestamp)) %>%
mutate(time_sameday = ymd_hm(paste(Sys.Date(),hour(time_only),minute(time_only))))
# Define UI for application that draws a histogram
ui <- fluidPage(
# Application title
titlePanel("ERCOT Generation by Fuel"),
#plot
plotOutput("Plot2", height = 700),
hr(),
# Sidebar with a slider input for date
fluidRow(
column(12,
wellPanel(
dateInput("Date_calendar",
label = "Select a Date:",
value = as.Date("2022-01-01"),
min = as.Date("2009-01-01","%Y-%m-%d"),
max = as.Date("2022-03-31","%Y-%m-%d")
),
uiOutput("slider")
)
)
)
)
# Define server logic required to draw a histogram
server <- function(input, output) {
output$Plot2 <- renderPlot({
df_datetime %>%
filter(Date %in% input$Date) %>%
ggplot(aes(x = time_sameday, y = Gen_MWh, fill = factor(Fuel, levels = c("Solar", "Wind", "Gas", "Gas CC", "All Other", "Hydro", "Coal", "Nuclear") ) )) +
geom_bar(position = "stack", stat='identity') +
scale_fill_manual(values = c("orange", "purple", "red", "pink1", "brown", "blue", "gray50", "gold"))+
scale_x_datetime(date_labels = "%H:%M")+
ylim(0,20000)+
xlab("Time of the Day")+
ylab("Generation (MWh)")+
guides(fill=guide_legend(title="Fuel Type"))
})
output$slider <- renderUI ({
sliderInput("Date",
"Date:",
min = as.Date("2009-01-01","%Y-%m-%d"),
max = as.Date("2022-03-31","%Y-%m-%d"),
value = input$Date_calendar, timeFormat="%Y-%m-%d",
step = 1,
animate = animationOptions(interval = 400,
playButton = icon("play", "fa-2x"),
pauseButton = icon("pause","fa-2x" ))
)
})
}
# Run the application
shinyApp(ui = ui, server = server)
logs when publishing:
2022-05-07T05:30:38.347878+00:00 shinyapps[6252822]: Running on host: 94e2e8808437
2022-05-07T05:30:38.347924+00:00 shinyapps[6252822]: Server version: 2022.03.1
2022-05-07T05:30:38.347959+00:00 shinyapps[6252822]: LANG: C.UTF-8
2022-05-07T05:30:38.347972+00:00 shinyapps[6252822]: Working directory: /srv/connect/apps/ERCOT_generation_shiny_app_dir
2022-05-07T05:30:38.348036+00:00 shinyapps[6252822]: R version: 4.0.5
2022-05-07T05:30:38.348084+00:00 shinyapps[6252822]: shiny version: 1.7.1
2022-05-07T05:30:38.348204+00:00 shinyapps[6252822]: rmarkdown version: (none)
2022-05-07T05:30:38.348148+00:00 shinyapps[6252822]: httpuv version: 1.6.5
2022-05-07T05:30:38.348261+00:00 shinyapps[6252822]: knitr version: (none)
2022-05-07T05:30:38.348308+00:00 shinyapps[6252822]: jsonlite version: 1.7.2
2022-05-07T05:30:38.348348+00:00 shinyapps[6252822]: RJSONIO version: (none)
2022-05-07T05:30:38.348395+00:00 shinyapps[6252822]: htmltools version: 0.5.2
2022-05-07T05:30:38.348434+00:00 shinyapps[6252822]: reticulate version: (none)
2022-05-07T05:30:38.348480+00:00 shinyapps[6252822]: Using pandoc: /opt/connect/ext/pandoc/2.16
2022-05-07T05:30:38.348523+00:00 shinyapps[6252822]: Using jsonlite for JSON processing
2022-05-07T05:30:38.348660+00:00 shinyapps[6252822]: Starting R with process ID: '26'
2022-05-07T05:30:38.348713+00:00 shinyapps[6252822]: Shiny application starting ...
2022-05-07T05:30:38.348757+00:00 shinyapps[6252822]:
2022-05-07T05:30:38.348566+00:00 shinyapps[6252822]:
2022-05-07T05:30:38.348807+00:00 shinyapps[6252822]: Attaching package: ‘rsconnect’
2022-05-07T05:30:38.348855+00:00 shinyapps[6252822]:
2022-05-07T05:30:38.348914+00:00 shinyapps[6252822]: The following object is masked from ‘package:shiny’:
2022-05-07T05:30:38.348964+00:00 shinyapps[6252822]:
2022-05-07T05:30:38.349095+00:00 shinyapps[6252822]:
2022-05-07T05:30:38.349010+00:00 shinyapps[6252822]: serverInfo
2022-05-07T05:30:38.349231+00:00 shinyapps[6252822]: The following objects are masked from ‘package:stats’:
2022-05-07T05:30:38.349051+00:00 shinyapps[6252822]:
2022-05-07T05:30:38.349181+00:00 shinyapps[6252822]:
2022-05-07T05:30:38.349282+00:00 shinyapps[6252822]:
2022-05-07T05:30:38.349135+00:00 shinyapps[6252822]: Attaching package: ‘dplyr’
2022-05-07T05:30:38.349410+00:00 shinyapps[6252822]:
2022-05-07T05:30:38.349367+00:00 shinyapps[6252822]: filter, lag
2022-05-07T05:30:38.349464+00:00 shinyapps[6252822]: The following objects are masked from ‘package:base’:
2022-05-07T05:30:38.349673+00:00 shinyapps[6252822]:
2022-05-07T05:30:38.349769+00:00 shinyapps[6252822]:
2022-05-07T05:30:38.349515+00:00 shinyapps[6252822]:
2022-05-07T05:30:38.349564+00:00 shinyapps[6252822]: intersect, setdiff, setequal, union
2022-05-07T05:30:38.349817+00:00 shinyapps[6252822]: The following objects are masked from ‘package:base’:
2022-05-07T05:30:38.349721+00:00 shinyapps[6252822]: Attaching package: ‘lubridate’
2022-05-07T05:30:38.349615+00:00 shinyapps[6252822]:
2022-05-07T05:30:38.349865+00:00 shinyapps[6252822]:
2022-05-07T05:30:38.349919+00:00 shinyapps[6252822]: date, intersect, setdiff, union
2022-05-07T05:30:38.349976+00:00 shinyapps[6252822]:
I'm deeply frustrated as I cannot find out what went wrong. I've ensured relative path and required package library calls. Any insight is greatly appreciated!