title: How to wrap a function around a reactive expression in R Shiny?
body: <h2>Minimal working example</h2>
  
  <p>Say I want to have a custom version of <code>renderDataTable</code>, which I shall name <code>myRenderDataTable</code> and works by wrapping around <code>renderDataTable</code>:</p>
  
  <pre><code>library(shiny)
  runApp(list(
      ui = basicPage(
          actionButton("button", "Increase input"),
          tabsetPanel(
              tabPanel("table1", shiny::dataTableOutput("table1")),
              tabPanel("table2", shiny::dataTableOutput("table2")),
              tabPanel("table3", shiny::dataTableOutput("table3"))
          )
      ),
      server = function(input, output) {
          myRenderDataTable &lt;- function(a) {
              renderDataTable(
                  data.frame(x = a, y = a^2, z = a^3),
                  options = list(bPaginate = as.logical(a %% 2))
              )
          }
          output$table1 &lt;- myRenderDataTable(input$button)
          output$table2 &lt;- myRenderDataTable(input$button + 1)
          output$table3 &lt;- myRenderDataTable(input$button + 2)
      }
  ))
  </code></pre>
  
  <h2>Issue</h2>
  
  <p>Unfortunately, it appears that <code>myRenderDataTable</code> is not reactive like <code>renderDataTable</code>. Clicking the <code>Increase input</code> button should cause the table values to change, but doesn't.</p>
  
  <p>So what's going wrong?</p>
  
  <h2>Attempt: Passing calls to <a href="http://www.inside-r.org/packages/cran/shiny/docs/is.reactive" rel="nofollow"><code>reactive</code></a>:</h2>
  
  <p>Doing <code>output$table1 &lt;- reactive(myRenderDataTable(input$button))</code>) leads to:</p>
  
  <pre><code>Error during wrapup: evaluation nested too deeply: infinite recursion / options(expressions=)?
  Error : evaluation nested too deeply: infinite recursion / options(expressions=)?
  </code></pre>
  
  <h2>Attempt: Passing calls to <a href="http://www.inside-r.org/packages/cran/shiny/docs/observe" rel="nofollow"><code>observe</code></a>:</h2>
  
  <p>Doing <code>observe(output$table1 &lt;- myRenderDataTable(input$button))</code> had no effect on the issue</p>