R Quick Tip: Upload multiple files in shiny and consolidate into a dataset

April 28, 2017

(This article was first published on R – Locke Data, and kindly contributed to R-bloggers)

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.

View the code on Gist.

The post R Quick Tip: Upload multiple files in shiny and consolidate into a dataset appeared first on Locke Data. Locke Data are a data science consultancy aimed at helping organisations get ready and get started with data science.

To leave a comment for the author, please follow the link and comment on their blog: R – Locke Data.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)