Shiny error: 'file' must be a character string or connection
r, shiny
Solution
You should be reading your file inside a reactive function. For example inside a renderTable.
You then need to add
if(is.null(input$file1)) return(NULL)
as the first thing in your reactive function.
The error is because you are trying to read a file with path NULL that is the value of input$file1 before a file is uploaded.
Update: shiny now has a function that deals more cleanly with this. You can instead add `req(input$file1)` at the start of your render function.
Problem
Question #1: My ui.R code: ``` fileInput('file1', h5('Choose input file: (Use only tab delimited text files)'), accept=c('text', 'text-separated-values')) ``` and server.R code ``` inFile <- input$file1 dat<-read.table(inFile$datapath, header=TRUE, sep="\t") ``` when I launch shiny, I am getting, `Error: 'file' must be a character string or connection`. But after uploading the file, the error goes away. I'm wondering what could be the problem? I'd appreciate any pointers! Question #2: How to suppress error message in R console, when shiny is running? Thanks in advance