assuming you want all of these tables to be rendered dynamically based on the number of different fac levels, you could use map (which is essentially, an efficient for loop) along with renderTable, renderUI and tableOutput:
You will need to load dplyr and purrr packages for the filter and map functions, respecitvely.
server.r
levels <- reactive({unique(prod()$fac})
observe({
map(levels(), ~{
output_name <- paste0("table_", .x)
output[[output_name]] <- renderTable(
prod() %>% filter(fac == .x)
)
})
})
output$table_ui_render <- renderUI({
table_list <- map(levels(), ~{
tableOutput(
outputId = paste0("table-", .x)
)
}
)
return(tagList(table_list))
})
ui.r
uiOutput("table_ui_render")