title: Call eventReactive for an arbitrary number of action buttons
body: <p>What I'm trying to do is create an arbitrary number of action button, each of which has their own event based on their own individual values.</p>
  
  <p>Let's say we want to create a number of buttons. What we do is draw a random number between 1 and 100 and call it <em>n</em>. Then we create <em>n</em> buttons, each with a value between <em>1</em> and <em>n</em> (covering every number once). Then, when we press one of those buttons, we render a text message being the number that we pressed. </p>
  
  <p>To set up the buttons, we have:</p>
  
  <p><strong>ui.R</strong></p>
  
  <pre><code>shinyUI(fluidPage(
     actionButton('roll','roll'),
     uiOutput('buttons')
  ))
  </code></pre>
  
  <p><strong>Server.R</strong></p>
  
  <pre><code>shinyServer(function(input, output) {
  
    n &lt;- eventReactive(input$roll, {
      num &lt;- sample(1:100,1)
      sample(1:num, num, replace=FALSE)
    })
  
    output$buttons &lt;- renderUI({
      lapply(1:length(n()), function(i) {
        actionButton(as.character(n()[i]), as.character(n()[i]) )
      })
    })
  
  })
  </code></pre>
  
  <p>This generates the buttons. However, I'm struggling to find a way to create all the necessary <code>eventReactive()</code>s. I tried calling <code>eventReactive()</code> inside a loop, and in a <code>lapply</code> call. However, in order to make that loop or <code>lapply</code>, you need the value of <code>length(n())</code>, which can only be called inside another reactive or observe command. </p>
  
  <p>Given the buttons generated from the above script, how do we make a reactive expression for each button, and then output the text corresponding to the number pressed?</p>