[Shiny 30本ノック]9. file uploadをたくさんつける
library(shiny)
ui <- fluidPage(
#title
titlePanel("test"),
#mainPanel
mainPanel(
fileInput("h5", "Choose .h5 file"),
fileInput("tcr", "Choose tcr file"),
fileInput("bcr", "Choose bcr file"),
)
)
server <- function(input, output, session) {
data <- reactive({
req(input$upload)
ext <- tools::file_ext(input$upload$name)
switch(ext,
csv = vroom::vroom(input$upload$datapath, delim = ","),
tsv = vroom::vroom(input$upload$datapath, delim = "\t"),
validate("Invalid file; Please upload a .csv or .tsv file")
)
})
output$head <- renderTable({
head(data(), input$n)
})
}
shinyApp(ui, server)