R Shiny and Uploading Data

Hi everyone,

I need to upload some data CSVs into Shiny using the file upload widget then perform analysis on all of the CSVs. Any tips or templates? Thank you!

ui <-
      inputId = "csvFiles",
      label = "Drag and drop here",
      multiple = TRUE,
      buttonLabel = "Browse...",
      placeholder = "No file selected"

server <- function(input, output, session) {
  # End user session when app is closed.
  if (!interactive()) {
    session$onSessionEnded(function() {
  renderedTableObj <- reactive({
  # Output the files.
  output$fileNames <- renderTable({
    # Return immediately if user doesn't select any files.
    if (is.null(input$csvFiles)) {

shinyApp(ui, server)

That's sort of the basic template if you like, I'll link some sample code I've found here:

Thank you. Where would I put my own analysis in after I upload the data?

You can either put it in a function within the server function - or if it’s quite big - extract it out to a separate function(outside of the server). But make sure you call that function within the server and make sure it’s inside a reactive element ‘reactive({ })’.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.