Jautis Jautis - 4 days ago 4x
R Question

R Shiny: 'error cannot open the connection'

so I have a Shiny app where I'm trying to read in a user-identified input file.

Towards that end, my ui.R has the line

fileInput("predictor2", label = "Predictor Values")
and I try to read the file using the line
predictor <- read.delim("input$predictor2")
in my server.R file.

However, I get a message saying
Error: Cannot open the connection
. If I don't try to read in the file and use another matrix of values, the code works fine. Any advice for how to fix this problem or more detail that would be useful?


You code is looking for a file with the literal name input$predictor2 which presumably does not exist. You first need to remove the quotes from around it, then add which column of the return actually has the path to the data, e.g.:


See the help for fileInput for an example that checks to make sure something has been uploaded first.