title: Using dynamic input from tagList to renderTable in Shiny
body: <p>What I am trying to do is have the user specify the number of groups then, based on the number of groups specified, the UI generates a <code>numericInput</code> for each group. Then I want to use that value to do some other operations (in this example, I'm making a table of means). Using <a href="https://stackoverflow.com/questions/36094718/r-shiny-dynamic-input">this example</a>, I was able to make it return some text, but not use that label as input for anything else. </p>
  
  <p>When I try to use that information (i.e., as reactive conductor), I get a "replacement has length zero" error. It seems shiny is not recognizing the updated UI. I know it probably has something to do with using <code>reactive</code>, but I can't figure out why it's not working. Here's my code:</p>
  
  <pre><code>library(shiny)
  library(purrr)
  
  # functions ---------------------------------------------------------------
  ## generic function that creates an input from an i
  make_list = function(i, idname, labelname){
    idname &lt;- paste(idname, i, sep = "")
    div(style="display: inline-block;vertical-align:top; width: 45%;",
        numericInput(idname, labelname, 0))
  }
  
  ## make function that can be used within a loop
  list_loop = function(i) {
    make_list(i, "mean", "Mean of Group ")
  }
  
  
  # UI ----------------------------------------------------------------------
  # Define UI for application that draws a histogram
  ui &lt;- fluidPage(
  
    # Application title
    titlePanel("A Test Page"),
  
    sidebarLayout(
      sidebarPanel(width = 8,
          #### UI for groups
         numericInput("groups", "How many groups?", 4),
         hr(),
         uiOutput("inputMean")),
  
      # Main panel for displaying outputs ----
      mainPanel(width = 4,
                h3("Data Preview"),
                #textOutput("inputValues"),
                tableOutput("table"))
      )
  )
  
  
  # Server ------------------------------------------------------------------
  # Define server logic required to draw a histogram
  server = function(input, output) {
  
    ## loop through # of groups for all i and make the UI
    ## this is passed back to the UI
    observeEvent(input$groups, 
        {
          output$inputMean = renderUI(
            {
              mean_list &lt;- 1:input$groups %&gt;% map(~list_loop(.x))
              do.call(tagList, mean_list)
            }
          )
      }
    ) 
  
    ## return the inputnames
    ## This WORKS
    output$inputValues &lt;- renderText({
      paste(lapply(1:input$groups, function(i) {
        inputName &lt;- paste("mean", i, sep = "")
        input[[inputName]]
      }))
    })
  
    make_table = reactive({
      ### prepopulate a table
      d = data.frame(group = 1:input$groups)
      d$means = NA
      paste(lapply(1:input$groups, function(i) {
        inputName &lt;- paste("mean", i, sep = "")
        # this fails because input is NULL at this point
        d$means[i] = input[[inputName]]
      }))
      d
    })
  
    output$table &lt;- renderTable({
      make_table()
    })
  }
  
  # Run the application 
  shinyApp(ui = ui, server = server)
  </code></pre>