Hello,
Given you only provided some dummy code and not the actual example, I have to guess what is going on in the background in your app, but from the look of it it seems an issue with not using the correct variable types.
Notice how in "observeEvent input$submit_2" you use the variable 'first_calc'. This is just a normal R variable and not a reactive shiny one. That means that the first time it's created it will have the correct value, but will not change anymore after that if you run it again. To fix this, you need to create a reactiveVal instead and update that so it will work when you run it again.
See below a dummy example of mine where a variable gets passed along. Notice how the values can be changed the second time around.
library(shiny)
ui <- fluidPage(
actionButton("start1", "Start!"),
uiOutput("myResult")
)
server <- function(input, output, session) {
passOn = reactiveVal()
observeEvent(input$start1, {
passOn(sample(1:50, 1))
showModal(modalDialog(
title = "Modal 1",
numericInput("val1", "Choose a value", value = passOn()),
footer = tagList(actionButton(inputId = "start2", "Continue"))
))
})
observeEvent(input$start2, {
passOn(input$val1)
showModal(modalDialog(
title = "Modal 2",
numericInput("val2", "Choose a value", value = passOn()),
footer = tagList(actionButton(inputId = "start3", "Continue"))
))
})
observeEvent(input$start3, {
passOn(input$val2)
showModal(modalDialog(
title = "Modal 3",
numericInput("val3", "Choose a value", value = passOn()),
footer = tagList(actionButton(inputId = "finished", "Finish!"))
))
})
observeEvent(input$finished, {
removeModal()
passOn(input$val3)
output$myResult = renderUI({
tags$h1(paste("The final value is", passOn()))
})
})
}
shinyApp(ui, server)
Hope this helps!
PJ