简体   繁体   中英

How can I upload my dataset with option to choose either xls,xlsx and csv for my Shiny Dashboard?

Im currently doing an application using Shiny Dashboard for dataset analytics application. But after using the tutorial by shiny dashboard, i found out that i couldnt upload xls, and xlsx type of files.

Sorry, first time using Shiny Dashboard.

You can take the file extension and use the appropriate file reader according to this extension.

In ui :

fileInput("file", "Upload a file")

In server :

dataset <- eventReactive(input$file, {
  extension <- tools::file_ext(input$file$name)
  filepath <- input$file$datapath
  switch(extension,
    csv = read.csv(filepath),
    xls = readxl::read_xls(filepath),
    xlsx = readxl::read_xlsx(filepath)
  )
})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM