server <- function(input, output, session) {
data <- reactive({
req(input$file)
name <- input$file$name
path <- input$file$datapath
ext <- tools::file_ext(name)
switch(ext,
csv = vroom::vroom(path, ","),
tsv = vroom::vroom(path, "\t"),
validate("Invalid file")
)
})
output$head <- renderTable({
head(data(), input$n)
})
}