R Quick Tip: Upload multiple files in shiny and consolidate into a dataset
In shiny, you can use the fileInput
with the parameter multiple = TRUE
to enable you to upload multiple files at once. But how do you process those multiple files in shiny and consolidate into a single dataset?
The bit we need from shiny is the input$param$fileinputpath
value.
We can use lapply()
with data.table‘s fread()
to read multiple CSVs from the fileInput()
. Then to consolidate the data, we can use data.table‘s rbindlist()
to consolidate these into a dataset.
For more info on using data.table for consolidating CSVs, read my post on rbindlist()
If you wanted to process things other CSVs then you might consider alternative libraries, and of course, you don’t just need to put them all into one big table.
https://gist.github.com/stephlocke/c3299992ef3ac3efe1f978bd1cb0b4b2