Skip to content

Instantly share code, notes, and snippets.

@stephlocke
Last active April 2, 2024 09:21
Show Gist options
  • Star 18 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save stephlocke/c3299992ef3ac3efe1f978bd1cb0b4b2 to your computer and use it in GitHub Desktop.
Save stephlocke/c3299992ef3ac3efe1f978bd1cb0b4b2 to your computer and use it in GitHub Desktop.
Demo shiny app for multiple file uploads and a single read step
library(shiny)
library(data.table)
ui <- fluidPage(
titlePanel("Multiple file uploads"),
sidebarLayout(
sidebarPanel(
fileInput("csvs",
label="Upload CSVs here",
multiple = TRUE)
),
mainPanel(
textOutput("count")
)
)
)
server <- function(input, output) {
mycsvs<-reactive({
rbindlist(lapply(input$csvs$datapath, fread),
use.names = TRUE, fill = TRUE)
})
output$count <- renderText(nrow(mycsvs()))
}
shinyApp(ui = ui, server = server)
@piercefa
Copy link

piercefa commented May 2, 2023

I added a step to view the data in a table, but it seems that the files (xlsx) are not actually combining. I am simply uploading a new file each time. Is there a step I am missing that combines each file I upload? Thank you so much for this demo!

@stephlocke
Copy link
Author

You may need to ctrl+click the files @piercefa you want to upload when in your file explorer window that pops up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment