我正在尝试将 .tab 文件导入到 R 中,但其中一行包含意外数量的元素,这给我带来了错误。
data <- read.table(functions.tab, header = F, sep = "\t")
Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, : line 397 did not have 4 elements
解决这个问题的最佳方法是什么,这样我就不会丢失任何信息?有没有办法将溢出元素合并到最后一列?
最佳答案
我们可以在 read.table
中使用 fill
参数来填充元素数量较少的行,由 NA
填充
data <- read.table(functions.tab, header = F, sep = "\t", fill = TRUE)
关于R:读取.tab文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41523318/