我需要读取一个表,该表是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'我该怎么读呢?
发布于 2015-10-25 03:26:15
这应该可以做到:
read.table(file = 'drug_info.tsv', sep = '\t', header = TRUE)发布于 2018-03-12 14:05:09
使用包data.table中的fread将读取数据,并跳过使用read.table时出现的错误。
require(data.table)
data<-as.data.frame(fread("drug_info.tsv"))发布于 2019-02-22 06:39:24
您可以将数据视为csv,并指定制表符分隔。
read.csv("drug_info.tsv", sep = "\t")https://stackoverflow.com/questions/33322248
复制相似问题