Hi Luis,
I think an option can be generate the html in renderUI, so you can have all your data (table, title, caption) in a tibble, and then with pmap, generate the html part: a div containting the title, the reactable and caption for every table and send that to the uiOutput.
library(shiny)
library(purrr)
library(dplyr)
library(reactable)
library(htmltools)
# input <- list(ntables = 4)
ui <- fluidPage(
mainPanel(
sliderInput("ntables", "# tables", min = 1, max = 4, value = 1),
uiOutput("tables", class = "row")
)
)
server <- function(input, output) {
output$tables <- renderUI({
n <- input$ntables
tablas <- map(1:n, function(i) as_tibble(matrix(rnorm(10 * i), ncol = i)))
titulos <- paste("titulo", 1:n)
captions <- paste("caption", 1:n)
tibble(
tbl = tablas,
tle = titulos,
cap = captions
) %>%
pmap(function(tbl, tle, cap){
tags$div(
class = "col-sm-4", # given by bootstrap
tags$h1(tle),
reactable(tbl),
tags$em(cap)
)
})
})
}
shinyApp(ui = ui, server = server)