我需要读取R中的.tsv文件的表。

r - 如何导入.tsv文件-LMLPHP

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.table(file = 'drug_info.tsv', sep = '\t', header = TRUE)

关于r - 如何导入.tsv文件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33322248/

10-12 19:57