title: How can I improve my code for generating a dynamic UI element?
body: <p>I have a dynamic Shiny UI element, where the user is prompted to select a number (1-4) from a dropdown. Shiny then responds by generating the corresponding number of numericInput() elements that will be used by my program. </p>
  
  <p>The following code works, but it's very long-winded and I imagine there are methods to improve the code to (1) make it more concise, and (2) avoid using if/else statements. </p>
  
  <pre class="lang-r prettyprint-override"><code>library(shiny)
  
  ui &lt;- fluidPage(
    sidebarLayout(
      sidebarPanel(
        selectInput("num", label = h3("Select box"), 
                    choices = list("Choice 1" = 1, "Choice 2" = 2, "Choice 3" = 3,
                                   "Choice 4" = 4), 
                    selected = 1),
        uiOutput("input_ui")
      ),
      mainPanel(
        tableOutput("table")
      )
    )
  )
  
  server &lt;- function(input, output) {
  
    output$input_ui &lt;- renderUI({
      num &lt;- as.integer(input$num)
      if (num == 1) {
        fluidRow(
          column(6, numericInput("min", h5("Min"), value = 10)))
      } else if (num == 2) {
        fluidRow(
          column(6, numericInput("min", h5("Min"), value = 10)),
          column(6, numericInput("max", h5("Max"), value = 15))
        )
      } else if (num == 3) {
        fluidRow(
          column(6, numericInput("min", h5("Min"), value = 10)),
          column(6, numericInput("max", h5("Max"), value = 15)),
          column(6, numericInput("max", h5("Max"), value = 20))
        )
      } else if (num == 4) {
        fluidRow(
          column(6, numericInput("min", h5("Min"), value = 10)),
          column(6, numericInput("max", h5("Max"), value = 15)),
          column(6, numericInput("max", h5("Max"), value = 20)),
          column(6, numericInput("max", h5("Max"), value = 25))
        )
      }
    })
  }
  
  shinyApp(ui = ui, server = server)
  </code></pre>
  
  <p>Is there a better way to write this?</p>
  
  <p>Note that in the above, the values and labels are arbitrary. </p>