'Reactive' hash


I would like to store the values of a set of numeric inputs into a single hash so that whenever the user changes one of them the hash is updated, kind of:

shinyServer(function(input, output, session) {
   tpl_info_A = reactive({hash(
    "TPL_EmissionsLimit"  = input$total_emissions
  output$display <- renderPrint({

but when I try to look at the value via the hash as in the display I get:

Error: object of type 'closure' is not subsettable

what am I missing?

Thanks for your help!


You’re only missing two brackets/parentheses!

When you use a reactive expression elsewhere (e.g. in your renderPrint() call) you need to use () after the reactive name.

So you can change your renderPrint() to:

output$display <- renderPrint({

(I removed the return() call, too, as you don’t need it).

For a good start to understanding reactivity, I’d recommend checking out the videos from the Shiny developer conference.