I am working on a Shiny App to find the best linear regression model for a data set. I want people to be able to input .txt, .xls, or .csv files. I havethis code in my ui.R :
fileInput("mydata", label = h4("Please upload the .xls, .txt, or.csv file you would like included in the analysis.")),
checkboxGroupInput("filetype", label = h4("Please select the type of data uploaded:"), choices = (".csv", ".txt", ".xls"), selected = ".xls"),
checkboxGroupInput("header", label = h4("Does your table have a header (column names)?"), choices = ("TRUE", "FALSE"), selected = "TRUE"),
I believe this should allow them to browse the computer for a file, upload it, then tell me the file type and if there are headers or not.
In my server.R, I am not sure how to tell my output to use one code if there is a .txt or .xls and another if there is a .csv. This is all I have so far:
dat <- read.table(input$mydata, header=input$header) #if .xls or .txt
dat <- read.csv(input$mydata, header=input$header) #if .csv
I have looked around, but can't seem to find any examples anywhere. Does anyone know what I can add to my server.R code to be able to differentiate this based on the box they chose?
Aucun commentaire:
Enregistrer un commentaire