title: Modify Values of a Reactive Dataframe in Shiny
body: <p>I am trying to build a Shiny app in which the user can &quot;look up&quot; rows in a data frame, and a reactive data frame records the count of how many times the user has looked up a each. My strategy is to append a column &quot;n&quot; (initially a column of 0's) to the data frame, and increment the &quot;n&quot; value of the appropriate observation by 1 each time that it is specified by the user. However, I have not found a way to implement such a reactive data frame.</p>
  <p>I've attached the relevant code below. In my case, the user specifies a row in the data frame using the variables &quot;id&quot;, and &quot;dob&quot;. The &quot;test&quot; variable and the if/else statement is simply a safeguard to ensure that the user-specified observation actually exists in the data frame. &quot;flag&quot; is the name of my reactive data frame. The value of &quot;n&quot; should increment every time the user interacts with the &quot;input$randomize&quot; action button.</p>
  <p>The error that I typically receive reads <strong>&quot;Warning: Error in &lt;-: invalid (NULL) left side of assignment.&quot;</strong></p>
  <p>I've searched through the related posts, but could not find one that satisfactorily addresses my situation. I hope I've explained things adequately. Please ask any questions where I've been unclear. Thanks in advance.</p>
  <pre><code>library(shiny)
  library(tidyverse)
  library(magrittr)
  
  df &lt;- read_csv(&quot;/filepath&quot;)
  df &lt;- add_column(n = 0)
  
  server &lt;- function(input, output) {
    flag &lt;- reactiveVal({df})
    
    # Data transformation function
    dataTransform &lt;- bindEvent(reactive({
      test = nrow(filter(flag(), id == input$id &amp; dob == input$dob))
      
      if (test == 0){
        return(NULL)
      }
      else {
        flag()[flag()$id == input$id &amp; flag()$dob == input$dob, &quot;n&quot;] %&lt;&gt;%
          + 1
  
          flag() %&gt;%
          filter(id == input$id &amp; dob == input$dob) %&gt;%
          select(id, dob, kit_id, n) %&gt;%
          return()
        }
      }), input$randomize
    )
  </code></pre>