I am working on a shiny app where a user can edit a data table directly in the main panel. I have added a button in each row, and I want now that when the user clicks on a button in a certain row, underneath it a row appears with the same value for 'Time' as is the case in the row where the user clicks on the button. So if the user clicks on 'add row' in a row where the time value is 2 then the time value for the new row should be 2 as well. In this row, no action button should be added. If the user would like to add another row with time value 2, he should again click on the row that existed initially. If possible, the new row should now appear underneath the first row that he added instead of underneath the row with the button. So that I have the rows chronologically in the way the user added them.
I have now following code, but I do not know how I can make the button work correctly.