Hello everyone, I'm wondering if someone could help me with the way a spinner is displaying in my app. The problem is that the spinner appears in the app as soon as I launch the app, which is not my intention. The spinner is supposed to appear only when the make plot button is clicked.
I also wonder if there is a way to display a message with the spinner, like Generating plot, please wait.
Below I attach the app in order to replicate what is happneing with it.
Thanks in advance !!
library(shiny)
library(fitdistrplus)
library(shinycssloaders)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
selectInput(inputId = "selectVar", label = "Select variable",
choices = c("var1", "var2")),
checkboxInput(inputId = "bootstrap", label = "Perform bootstrap", value = F),
conditionalPanel(condition = "input.bootstrap == true",
sliderInput(inputId = "slider1", label = "Select sample size for bootstrap",
min = 1000, max = 50000, value = 5000, step = 1000 )),
actionButton(inputId = "boton1", label = "Make plot")
),
mainPanel(
br(),
tabPanel(title = "tab1",
withSpinner(plotOutput(outputId = "CyF"),
type = getOption("spinner.type", default = 4), hide.ui = T))
)
)
)
server <- function(input, output, session) {
data <- reactive({
var1 <- rnorm(1000, 0, 1)
var2 <- rnorm(1000,10,5)
cbind(var1, var2)
})
observeEvent(input$boton1, {
output$CyF <- renderPlot({
if(isolate(input$bootstrap==F)){
descdist(data()[,isolate(input$selectVar)])
} else {
descdist(data()[,isolate(input$selectVar)], boot = isolate(input$slider1))
}
})
})
}
shinyApp(ui = ui, server = server)