I am trying to delete the rows from a dataframe when they have been selected in the datatable and someone presses the "Delete Rows" switch. input$click_rows_selected gives the id's of the selected rows.
There seems to be something wrong with my use of observeEvent and observe, because the code deletes the selected rows the first time I flick the switch. Afterwards however, every time I select a row it also deletes that row. How do I get to stop deleting the row once the switch has been turned off? The if and else statement don't seem to help at all.
Shortened version of the code:
observeEvent(input$deleterows,{
if(input$deleterows==TRUE){
observe({
if (is.null(input$click_rows_selected))
return()
values$df <- values[input$click_rows_selected,]})} else{
print("check")}
})