【发布时间】:2016-01-24 03:57:53
【问题描述】:
我需要读取 R 中 .tsv 文件的表。
test <- read.table(file='drug_info.tsv')
# Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
# line 1 did not have 10 elements
test <- read.table(file='drug_info.tsv', )
# Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
# line 1 did not have 10 elements
scan("drug_info.tsv")
# Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
# scan() expected 'a real', got 'ChallengeName'
scan(file = "drug_info.tsv")
# Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
# scan() expected 'a real', got 'ChallengeName'
我应该如何阅读它?
【问题讨论】:
-
请将文件的前 5 行复制/粘贴到您的问题中并删除图片。
-
使用默认设置的
read.delim -
read.table默认使用空格分隔(通常表示空格或制表符)。如果您有空格,您可以使用sep="\t"将分隔符显式设置为制表符。read.table适用于有效的输入文件,因此如果导入数据时出现问题,则与文件有关,而不是函数。因此,为了帮助您,我们需要您分享您实际尝试导入的文件样本,而不是其他程序中的数据图片。
标签: r import read.table readr