我需要在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'
我该如何阅读它?
read.delim
。 - rawrread.table
默认使用空格分隔符(即通常的空格或制表符)。如果有空格,您可以使用sep="\t"
显式设置分隔符为制表符。read.table
适用于有效的输入文件,因此如果导入数据时出现问题,则是文件而不是函数的问题。因此,为了帮助您,我们需要您分享实际尝试导入的文件样本,而不是其他程序中数据的图片。 - MrFlick