Q:

Dynamic input widgets in matrix form in shiny

I have developed a application using shiny which allow user to input number of rows and columns of his choice and then it will display accordingly that many number of input widgets accordingly in main panel. Currently with 1 column and as many rows it’s working.
My challenge is to replicate the same if user selects more than 1 column and those new columns should be adjacent to existing widgets in main panel in matrix form. 
How to do that? 
My code:
library(shiny)

ui <- shinyUI(fluidPage(
  titlePanel(title = "Adding input widgets horizontally and dynamically"), 
  sidebarLayout(

    sidebarPanel(numericInput("rows","Input No. of rows",value = 5),
                 br(),
                 numericInput("col","input No of col",value = 1)),

    mainPanel(uiOutput("plo"))
  )
)
)

server <- function(input,output){

  output$plo <- renderUI({

    lapply(seq(input$rows),function(i){
      numericInput(inputId = paste0("range",i),label = "col1",value = i)  
    })
  })
}

shinyApp(ui,server)

A:

You can do that in a very similar fashion, use another lapply to wrap the inner lapply with a column. Try the following:
library(shiny)

ui <- shinyUI(fluidPage(
  titlePanel(title = "Adding input widgets horizontally and dynamically"), 
  sidebarLayout(

    sidebarPanel(numericInput("rows","Input No. of rows",value = 5,min=1),
                 br(),
                 numericInput("col","input No of col",value = 1,min=1)),

    mainPanel(uiOutput("plo"))
  )
)
)

server <- function(input,output){

  output$plo <- renderUI({

    lapply(seq(input$col), function(j){
      column(width=3,
      lapply(seq(input$rows),function(i){
        numericInput(inputId = paste0("range",i,"_",j),label = "col1",value = i)  
      })
      )
    })
  })
}

shinyApp(ui,server)

Hope this helps!

