R 闪亮:'error cannot open the connection'

R Shiny: 'error cannot open the connection'

所以我有一个闪亮的应用程序,我试图在其中读取用户识别的输入文件。

为此,我的 ui.R 有 fileInput("predictor2", label = "Predictor Values") 行,我尝试使用 server.R 文件中的 predictor <- read.delim("input$predictor2") 行读取文件。

但是,我收到一条消息说 Error: Cannot open the connection。如果我不尝试读取文件并使用另一个值矩阵,则代码可以正常工作。有关如何解决此问题的任何建议或更多有用的详细信息?

您的代码正在查找文字名称为 input$predictor2 的文件,该文件可能不存在。您首先需要从它周围删除引号,然后添加 return 的哪一列实际上具有数据路径,例如:

read.delim(input$predictor2$datapath)

请参阅 fileInput 的帮助,查看检查以确保已先上传内容的示例。