I have a app that works just fine without adding shinycssloaders package. But for some reason, after I added the package and added the lines (see below), it stopped working if I deploy it with shinyapps.io. The app runs fine locally, just wouldn't let me deploy it.
# load the library
library(shinycssloaders)
withSpinner(plotOutput("my_plot"))
# if you have `%>%` loaded, you can do plotOutput("my_plot") %>% withSpinner()
The error message I'm getting in the log is attached down below, but I have package shinycssloaders, and I've tried downloading it from CRAN and github, but neither works.
2019-05-13T16:41:39.317482+00:00 shinyapps[890504]: Using pandoc at /opt/connect/ext/pandoc2
2019-05-13T16:41:39.538904+00:00 shinyapps[890504]: Listening on http://127.0.0.1:46817
2019-05-13T16:41:43.893648+00:00 shinyapps[890504]: Warning: Error in withSpinner: could not find function "withSpinner"
2019-05-13T16:41:43.908035+00:00 shinyapps[890504]: 68: div
2019-05-13T16:41:43.908036+00:00 shinyapps[890504]: 67: mainPanel
2019-05-13T16:41:43.908034+00:00 shinyapps[890504]: 69: tags$div
2019-05-13T16:41:43.908032+00:00 shinyapps[890504]: 70: tag
I'm sure this work because it is on their github page, but I'm not sure what I did wrong. Worst case scenario, I'll just get rid of it so it's not a huge issue, but it'd be cool if I can use it. Any help is appreciated!
EDIT So I attached a sample code, feel free try to deploy it, did't work for me. But works fine locally (since it's a sample app, the loading spinner is extremely quick, but you'd still be able to see it).
library(shiny)
library(shinycssloaders)
ui <- fluidPage(
actionButton("go", "Go"),
numericInput("n", "n", 50),
withSpinner(plotOutput("my_plot"))
)
server <- function(input, output) {
randomVals <- eventReactive(input$go, {
runif(input$n)
})
output$my_plot <- renderPlot({
hist(randomVals())
})
}
shinyApp(ui, server)
Since the log says Warning: Error in withSpinner: could not find function "withSpinner"
I went ahead added the package name in front of withSpinner
function, so now in the UI function, it should be
shinycssloaders::withSpinner(plotOutput("my_plot", height = 600))
and it works perfect with deploy. Although it seems bizarre, because I indeed attached library(shinycssloaders). In my actual app, I attached it in server.R file, perhaps that's why.