I have a doubt about actionButton and submitButton in Shiny. I want to develop a simulator, but i need to ensure that the simulation will run ONLY if the button "simulate" is pressed.
The main issue is that, after the button is pressed one time, the output table starts to update its values when some input is changed even if the "simulate" button is not pressed. I need that the output update just right after the "simulate" button is clicked.
How can i prevent that? I tried to change the combination of the arguments "once", "ignoreINIT" and "ignoreNULL" in the observeEvent function, but without success.
I wrote a very simple app that shows the behavior that i want to solve, as it follows:
library(shiny)
ui <- fluidPage(
# Application title
titlePanel("Action Button Doubt app"),
sidebarLayout(
sidebarPanel(
numericInput("n1","Number 1",value = NULL,min = 0,max = 50),
numericInput("n2","Number 2",value = NULL,min = 0,max = 50),
numericInput("n3","Number 3",value = NULL,min = 0,max = 50),
textInput("t1","Text 1",value = NULL),
actionButton("go","Simulate")
),
mainPanel(
DT::dataTableOutput("out")
)
)
)
server <- function(input, output) {
observeEvent(input$go,{
Value1 <- reactive(input$n1 + 10)
Value2 <- reactive(input$n2 + 20)
Value3 <- reactive(input$n3 + 30)
output$out <- DT::renderDataTable(DT::datatable(data.frame(Value1(),Value2(),Value3(),input$t1)))
})
}
shinyApp(ui = ui, server = server)
Can anyone help me with that? I found some topics with similar issues, tried to use the function "reset" from the shinyjs package, but still not helped me.
Thanks in advance