首页 > 解决方案 > 为什么 read.delim() 无法打开文本文件?

问题描述

我已将 Excel 文件保存为制表符分隔,但当我尝试打开它时,出现以下错误:

a=read.delim("GBM tab")
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") : cannot open file 'GBM tab': No such file or directory

虽然我的工作目录中有一个名为 GBM 选项卡的文本文件。即使按 Tab,也找不到匹配项。问题是什么?

标签: rdata-import

解决方案


一种更简单的选择是使用file.choose()然后直接指向目录中的文件

a <- read.delim(file.choose())

在 OP 的代码中,可能需要指定文件.txt或文件.csv末尾

a <- read.delim("GBM tab.txt")

推荐阅读