title: Delete specific row in r shiny
body: <p>I am currently programming a shiny app in which the user can add and delete lines to a data frame.</p>
  
  <p>To do so, I first initialize the data frame inside the <code>shinyServer</code> function using:</p>
  
  <pre><code>values &lt;- reactiveValues()
  values$df &lt;- data.frame(v1 = NA,
                        v2 = NA,
                        v3 = NA,
                        v4 = NA,
                        v5 = NA,
                        v6 = NA,
                        v7 = NA,
                        v8 = NA
                        )
  </code></pre>
  
  <p>Next, I have a button and the corresponding code to add lines to the <code>reactiveValue</code>:</p>
  
  <pre><code>newEntry &lt;- observe({
   if(input$add.button &gt; 0) {
  
   new.value &lt;- isolate(input$v1 * input$v2 * input$v3 * input$v4)
  
   newRow &lt;- isolate(c(input$v1, input$v2, input$v3, input$v4, 
                        input$v5, input$v6, input$v7, new.value))
  
   isolate(values$df &lt;- rbind(values$df, newRow))
  }
  
  })
  </code></pre>
  
  <p>So far, this code works perfect for me. Finally, I want to allow the user to remove the last row, or specific rows from the data frame. To do so, I have a delete button (<code>input$delete.button</code>) and a <code>numericInput()</code> to select the row. The logic I wanted to implement should be: if no specific row is selected, delete the last row, else delete the selected row. The code I tried so for is: </p>
  
  <pre><code>deleteEntry &lt;- observe({
   if(input$delete.button &gt; 0) {
  
  
    if(is.na(input$row.selection)){
  
      values$df &lt;- isolate(values$df[-nrow(values$df), ])
  
    } else {
  
      what does here?
  
    }
  }
  
  })
  </code></pre>
  
  <p>So the first statement, deleting the last row works, but deleting a specific row always fails. I tried different attempts including <code>eventReactive()</code> but nothing works so far. </p>
  
  <p><strong>Edit:</strong>
  This is the relevant part of my ui.r:</p>
  
  <pre><code># Add button
  actionButton(inputId = "add.button", label = "Add", icon = icon("plus")), 
  
  # Delete button 
  actionButton(inputId = "delete.button", label = "Delete", icon = icon("minus")),
  
  # Row selection
  numericInput(inputId = "row.selection", label = "Select row to be deleted", min = 1, max = 100, value = ""),
  </code></pre>
  
  <p>Any ideas to to implement this logic?
  Best, 
  Fabian</p>