title: R shiny use dynamic UI's input to multiply by group summed values
body: <p>This is an extension of my previous problem. I have a numericInput called <code>Number of modalities</code>. When the <code>Number of modalities</code> changes, there will be more modality minutes, and more groups of columns. Please refer to the below 2 pics for illustration.</p>
  <p>Now what I want is, the value inside modality minutes to multiply by its group sum, and finally the sum of the whole group. For example, if there are 2 <code>Number of modalities</code>, I want a column called <code>Total_minutes</code> = (<code>2WW1</code>+<code>Urgent1</code>+<code>Routine1</code>)* <code>value inside Modality 1 minutes</code> + (<code>2WW2</code>+<code>Urgent2</code>+<code>Routine2</code>)* <code>value inside Modality 2 minutes</code>.</p>
  <p>Although the value at the moment are all <code>1</code> inside those columns, but those values will be varied in real world use.</p>
  <p>Please help, I've been stuck for a long time on this problem and would really appreciate any help, thanks!</p>
  <p><a href="https://i.stack.imgur.com/bARWz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bARWz.png" alt="pic1" /></a></p>
  <p><a href="https://i.stack.imgur.com/s38BK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/s38BK.png" alt="pic2" /></a></p>
  <pre><code>library(shiny)
  library(reactable)
  library(tidyverse)
  
  
  ui &lt;- fluidPage(
    sidebarLayout(
      sidebarPanel(
        numericInput(&quot;No_modalities&quot;, label = &quot;Number of modalities&quot;,
                     value = 1, min = 1, max = 100, step = 1),
        textInput(&quot;urgency1&quot;, label = &quot;Urgency 1&quot;, value = &quot;2WW&quot;),
        textInput(&quot;urgency2&quot;, label = &quot;Urgency 2&quot;, value = &quot;Urgent&quot;),
        textInput(&quot;urgency3&quot;, label = &quot;Urgency 3&quot;, value = &quot;Routine&quot;),
        uiOutput(&quot;modality&quot;),
        width = 3
      ),
      mainPanel(
        reactableOutput(&quot;template&quot;),
        textOutput(&quot;check&quot;)
        , width = 9
      )
    )
  )
  
  server &lt;- function(input, output, session) {
    modality_names &lt;- reactive(paste0(&quot;Modality &quot;, seq_len(input$No_modalities)))
    
    output$modality &lt;- renderUI({
      map(modality_names(), ~ textInput(.x, label = paste(.x,&quot; minutes&quot;),
                                        value = isolate(input[[.x]])))
    })
    
    df1 = reactive({
      tibble(Column1 = rep(1,10), Column2 = rep(2,10))
    })
    
    # columns to add
    columnsToAdd = reactive({
      c(outer(c(input$urgency1,input$urgency2,input$urgency3),
              seq_len(input$No_modalities), paste0))
    })
    
    df2 = reactive({add_column(df1(),!!!set_names(as.list(rep(1,
                                                              length(columnsToAdd()))),
                                                  nm=columnsToAdd()))})
    
    output$template = renderReactable({
      reactable(df2())
    })
    
    
  }
  
  shinyApp(ui, server)
  </code></pre>