Escape a process of a for-loop upon button-click

Hi All!

I am dealing with an issue that was originally raised here. I am not sure whether the poster was able to resolve it, and the link that was provided in a response is not working at this point. So here I am with this question again.

In my shiny-app there is a for loop that is executed with a action button (titled RUN). The loop runs a long process, which I hope to make escapable. I want to have a separate STOP action button to stop the loop execution without shutting down the whole app.

I found that "break" function can be used, it works well when I set some sort of breaking condition. However I am not able to link the breaking condition to an action button.

I essentially created a button with "actionButton("stop", "STOP")

and I included the code below inside the for loop

if (input$stop != 0) {
break
}

The idea is that the value stored in an action button is 0, if it has not been pressed. This is not working for me.

What are the options available in Shiny to stop a for loop execution if an action button is pressed?

Best regards,
M.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.