title: Dynamically Create and User Input Boxes Shiny
body: <p>I am trying to create a shiny user interface with a dynamic reactive UI.</p>
  
  <p>Essentially a user has to input the number of variants for an experiment (1-10).</p>
  
  <p>For each variant the user is required to enter the variant name in a textbox and also a proportion 1 - 100 to allocate to each variant. The sum of proportions across all variants should add to 100.</p>
  
  <p>e.g. User selects 5 variants. Then for each variant 1-5 the user should get dropdowns to select proportions.</p>
  
  <ul>
  <li>Variant 1 proportion (1-100), user selects 40 say</li>
  <li>Variant 2 proportion (1-60),  user selects 10 say</li>
  <li>Variant 3 proportion (1-50),  user selects 35 say</li>
  <li>Variant 4 proportion (1-15),  user selects 10 say</li>
  <li>Variant 5 proportion (5),  user has no say in allocating this - the proportion is backed out as 100 - (v1 + v2 + v3 + v4) = 5</li>
  </ul>
  
  <p>I have borrowed code from here to start this:
  <a href="https://stackoverflow.com/questions/29305395/producing-dynamic-multiple-input-boxes-to-collect-data-depending-on-user-selecti">Producing dynamic/multiple input boxes to collect data depending on user selection in Shiny R</a></p>
  
  <p>ui.R</p>
  
  <pre><code>library(shiny)
  
  shinyUI(pageWithSidebar (
  
    headerPanel( "Portfolio Returns"),
  
    sidebarPanel(
      numericInput("assets", label = "Enter Number of variants in Experiment", value="1"),
      uiOutput("variants")
    ),
    mainPanel()
  ))
  </code></pre>
  
  <p>Server.R</p>
  
  <pre><code>library(shiny)
  
  shinyServer( function(input, output, session) {
  
    output$variants &lt;- renderUI({
      numAssets &lt;- as.integer(input$assets)
  
      lapply(1:numAssets, function(i) {
        list(tags$p(tags$u(h4(paste0("Variant ", i, ":")))),
             textInput(paste0("variant", i), label = "Variant Name", value = paste0("Variant ", i, " name..."))
             , numericInput(paste0("weight", i)
                            , label = "Proportion allocated (0 - 100)", value=0))
      })
    })
  })
  </code></pre>
  
  <p>Could anyone please assist with the above?</p>