Right now, the input boxes boxes display one below another. I would like to be able to display them in a matrix such that there are input$numoc
rows and input$inp1
columns.
UI
numericInput("cols", "Enter number of columns:",min=1,1),
numericInput("rows", "Enter number of rows:",min=1,1)
Server
output$matrixx <- renderUI({
k= rep(c(1:input$rows), times = input$cols)
mx<-max(input$rows,input$cols)
lllist <- lapply(1:(input$cols*input$rows), function(i, j=((i-1)%/%input$rows)+1, y=k[[i]]) {
iids <- paste("inp2", i, sep="")
names<- paste("Treatment #",j," Outcome #",y,sep="")
list(
numericInput(iids,names, value=0, min=0, max=1, step=0.05)
)
})
do.call(tagList, unlist(lllist, recursive = FALSE))
})
Sure, we can add
fluidRow
andcolumn
inside ourrenderUI
to achieve this.Here is a minimal example:
For simplicity I limited it to 4 columns and wrote it in a more repetitive, but easier to read format. At the cost of extra complexity you could make it work with more columns, and shorten it by using additional loops.