title: Reactive shiny modules sharing data
body: <p>I'm trying to create a shiny app using modules. Two dataframes (tables a and b) are reactive and can be modified, a third dataframe (table c) is also reactive and is based on tables a and b. </p>
  
  <p>I tried following this <a href="https://stackoverflow.com/questions/46555355/passing-data-within-shiny-modules-from-module-1-to-module-2">question</a> which does the same with text input and not dataframes, but my code isn't working - I get an <code>object of type closure is not subsettable error</code>. </p>
  
  <p>Thanks for any help.</p>
  
  <pre><code>### Libraries
  library(shiny)
  library(tidyverse)
  library(DT)    
  
  ### Data----------------------------------------
  
  table_a &lt;- data.frame(
    id=seq(from=1,to=10),
    x_1=rnorm(n=10,mean=0,sd=10),
    x_2=rnorm(n=10,mean=0,sd=10),
    x_3=rnorm(n=10,mean=0,sd=10),
    x_4=rnorm(n=10,mean=0,sd=10)
  ) %&gt;% 
    mutate_all(round,3)
  
  table_b &lt;- data.frame(
    id=seq(from=1,to=10),
    x_5=rnorm(n=10,mean=0,sd=10),
    x_6=rnorm(n=10,mean=0,sd=10),
    x_7=rnorm(n=10,mean=0,sd=10),
    x_8=rnorm(n=10,mean=0,sd=10)
  )%&gt;% 
    mutate_all(round,3)
  
  
  ### Modules------------------------------------ 
  
  mod_table_a &lt;- function(input, output, session, data_in,reset_a) {
  
    v &lt;- reactiveValues(data = data_in)
    proxy = dataTableProxy("table_a")
  
    #set var 2
    observeEvent(reset_a(), {
      v$data[,"x_2"] &lt;- round(rnorm(n=10,mean=0,sd=10),3)
      replaceData(proxy, v$data, resetPaging = FALSE) 
    })
  
    # render table
    output$table_a &lt;- DT::renderDataTable({
  
      DT::datatable(
        data=v$data,
        editable = TRUE,
        rownames = FALSE,
        class="compact cell-border",
        selection = list(mode = "single", 
                         target = "row"
                         ),
        options = list(
          dom="t",
          autoWidth=TRUE,
          scrollX = TRUE,
          ordering=FALSE,
          bLengthChange= FALSE,
          searching=FALSE
        )
      )
    })
  
    return(v)
  
  }
  
  mod_table_b &lt;- function(input, output, session, data_in,reset_b) {
  
    v &lt;- reactiveValues(data = data_in)
    proxy = dataTableProxy("table_b")
  
    #reset var
    observeEvent(reset_b(), {
      v$data[,"x_6"] &lt;- round(rnorm(n=10,mean=0,sd=10),3)
      replaceData(proxy, v$data, resetPaging = FALSE)  # replaces data displayed by the updated table
    })
  
    # render table
    output$table_b &lt;- DT::renderDataTable({
  
      DT::datatable(
        data=v$data,
        editable = TRUE,
        rownames = FALSE,
        class="compact cell-border",
        selection = list(mode = "single", 
                         target = "row"
        ),
        options = list(
          dom="t",
          autoWidth=TRUE,
          scrollX = TRUE,
          ordering=FALSE,
          bLengthChange= FALSE,
          searching=FALSE
        )
      )
    })
  
    return(v)
  }
  
  mod_table_c &lt;- function(input, output, session, tbl_a_proxy,tbl_b_proxy) {
  
    v &lt;- reactive({
    table_c &lt;- data.frame(id=seq(from=1,to=10)) %&gt;%
      left_join(tbl_a_proxy$data,by="id") %&gt;%
      left_join(tbl_b_proxy$data,by="id") %&gt;%
      mutate(y_1=x_1+x_6)%&gt;%
      select(x_2,x_6,y_1)
    })
  
  
    # render table
    output$table_c &lt;- DT::renderDataTable({
  
      DT::datatable(
        data=v$table_c,
        editable = TRUE,
        rownames = FALSE,
        class="compact cell-border",
        selection = list(mode = "single", 
                         target = "row"
        ),
        options = list(
          dom="t",
          autoWidth=TRUE,
          scrollX = TRUE,
          ordering=FALSE,
          bLengthChange= FALSE,
          searching=FALSE
        )
      )
    })
  }
  
  
  modFunctionUI &lt;- function(id) {
    ns &lt;- NS(id)
    DT::dataTableOutput(ns(id))
  }
  
  
  ### Shiny App---------
  #ui----------------------------------
    ui &lt;- fluidPage(
      fluidRow(
        br(),
        column(1,
               br(),
               actionButton(inputId = "reset_a", "Reset a")
               ),
        column(6,
               modFunctionUI("table_a")
        ),
        column(1),
        column(4)
      ),
      fluidRow(
        br(),
        br(),
        column(1,
               br(),
               actionButton(inputId = "reset_b", "Reset b")),
        column(6,
               modFunctionUI("table_b")
        ),
        column(5,
               modFunctionUI("table_c")
               )
      ),
      #set font size of tables
      useShinyjs(),
      inlineCSS(list("table" = "font-size: 10px"))
    )
  
  #server--------------
    server &lt;-  function(input, output) {
  
      #table a
      tbl_a_proxy &lt;- callModule(module=mod_table_a,
                 id="table_a",
                 data_in=table_a,
                 reset_a = reactive(input$reset_a)
      )
  
      #table b
      tbl_b_proxy &lt;- callModule(module=mod_table_b,
                 id="table_b",
                 data_in=table_b,
                 reset_b = reactive(input$reset_b)
      )
  
      #table c
      callModule(module=mod_table_c,
                 id="table_c",
                 tbl_a_proxy,
                 tbl_b_proxy
      )
  
    }  
  
  
    shinyApp(ui, server)
  </code></pre>