How to create Shiny R dynamic renderTable, with a number of tables determined by the uploaded CSV files?
<p>I am building web app that after uploading csv files transforms the data and then should be able to output few tables. The number of the tables depends strictly on the information included in the csv files, therefore is calculated during the data transformation process. I have created a list <code>lst</code> with data frames that have to be outputted. The length of the list is the number of the tables that should be created. After searching the web I encountered very similar question (<a href="https://stackoverflow.com/questions/26931173/shiny-r-renderplots-on-the-fly">here</a>), which is unfortunately not answered yet. Does anyone has an idea how to solve it?</p>

<p>Some of my code (not all, due to significant data transformation), where I would like to replace fixed <code>max_table</code> with variable <code>length(data_set())</code>:</p>

<pre><code>library(shiny)

ui &lt;- fluidPage(
  fluidRow(column(3,
                  wellPanel(
                    fileInput(inputId = "files",
                              label = "Choose cvs files",
                              accept=c('text/csv', 
                                       'text/comma-separated-values,text/plain', 
                                       '.csv'),
                              multiple = TRUE))),
           column(5, offset = 1, 
                  uiOutput("tables")
                  )
           )
  )

max_table &lt;- 5
server &lt;- function(input,output){


  data_set &lt;- reactive({
    if(is.null(input$files)){
      return(NULL)
    }

    lst &lt;- list()
    for(i in 1:length(input$files[,1])){
      lst[[i]] &lt;- read.csv(input$files[[i, 'datapath']], sep = ",", header = TRUE, skip = 4, dec = ".")
    }
    lst
  })

  output$tables &lt;- renderUI({
    plot_output_list &lt;- lapply(1:max_table, function(i) {
      tablename &lt;- paste("tablename", i, sep="")
      tableOutput(tablename)
    })
    do.call(tagList, plot_output_list)
  })


  for (i in 1:max_table){
    local({
      my_i &lt;- i
      tablename &lt;- paste("tablename", my_i, sep="")
      output[[tablename]] &lt;- renderTable({data_set()[[my_i]] 
      })
    })    
  }
}

shinyApp(ui = ui, server = server)
</code></pre>

<p>Any help would be much appreciated! </p>