title: How to add comment to a reactive data table in shiny
body: <p>This question is an extension of the question I posted: <a href="https://stackoverflow.com/questions/56503342/add-text-comments-to-a-datatable-in-shiny/56504173?noredirect=1#comment99613376_56504173">this question</a></p>
  
  <p>I created a dataframe with 3 columns: num, id and val. I want my shiny app to do the following:</p>
  
  <ol>
  <li>a dataframe <code>dat</code> is filtered by num column</li>
  <li>select an value from id column from <code>dat</code> (selectInput).</li>
  <li>add text comment in a text box (textInput)</li>
  <li>click on an action button</li>
  <li>A new column called comment is created in the data table, text comments are added to the comment column in the row where id equals the value selected.</li>
  </ol>
  
  <p>The code is below. I cannot figure out why it's not working. </p>
  
  <p>Thank a lot in advance!</p>
  
  <pre><code>    library(shiny)
      library(DT)
      dat = data.frame(num=rep(1:2, each=5), id=rep(LETTERS[1:5],2), val=rnorm(10)) 
      ui = fluidPage(
          fluidRow(
              column(12, selectInput('selectNum', label='Select Num', 
                                   choices=1:10, selected='')),
              column(2, selectInput(inputId = 'selectID',
                                    label = 'Select ID2',
                                    choices = LETTERS[1:10],
                                    selected='',
                                    multiple=TRUE)),
              column(6, textInput(inputId = 'comment', 
                                  label ='Please add comment in the text box:', 
                                  value = "", width = NULL,
                                  placeholder = NULL)),
              column(2, actionButton(inputId = "button", 
                                     label = "Add Comment"))
          ),
          fluidRow (
              column(12, DT::dataTableOutput('data') ) 
          )           
      )
  
      server &lt;- function(input, output, session) {
  
       ## make df reactive
  
       df = reactive ({ dat %&gt;% filter(num %in% input$selectNum) })
       df_current &lt;- reactiveVal(df())
  
       observeEvent(input$button, {
  
        req(df_current())
  
        ## update df by adding comments
        df_new &lt;- df_current()
        df_new[df_current()$id %in% input$selectID, "Comment"] &lt;- input$comment
  
        df_current(df_new)
  
        })
  
        output$data &lt;- DT::renderDataTable({
  
        req(df_current())
  
        DT::datatable(df_current(), 
            options = list(orderClasses = TRUE,
                lengthMenu = c(5, 10, 20), pageLength = 5))
       })
  
      shinyApp(ui=ui, server=server)
  </code></pre>