r - 为什么 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,也找不到匹配项。问题是什么?
解决方案
一种更简单的选择是使用file.choose()
然后直接指向目录中的文件
a <- read.delim(file.choose())
在 OP 的代码中,可能需要指定文件.txt
或文件.csv
末尾
a <- read.delim("GBM tab.txt")
推荐阅读
- javascript - 如何让这个按钮触发适当的事件
- azure-data-explorer - 如何检查给定数据库中所有表的表级策略(例如缓存)?
- html - Shopify Liquid:连续 for 循环无序迭代
- docker - Docker 不会将文件复制到创建的目录
- java - 如何在 java 条件语句中使用 or ,例如 if (a or b != c)
- javascript - Javascript `await` "SyntaxError: Unexpted identifier" 即使我在 `async` 函数中等待
- r - 如何从协方差矩阵中获取唯一对?
- puppeteer - 通过句柄循环获取内部元素文本
- php - 如何修复“将元素添加到数组而不是替换它”?
- javascript - $.getJSON 适用于本地主机但不适用于远程服务器