0

我正在使用以下代码从本地目录同时加载一堆 csv 文件:

myfiles = do.call(rbind, lapply(files, function(x) read.table(x, stringsAsFactors = FALSE, header = F, fill = T, sep=",", quote=NULL)))

并收到一条错误消息:

Error in rbind(deparse.level, ...) : 
  numbers of columns of arguments do not match

我担心引号会导致这种情况,因为我检查了 4 个文件中每个文件的列数,我发现文件号 3 包含 10 列(不正确),其余的只有 9 列(正确)。查看损坏的文件 - 它肯定是由导致列拆分的引号引起的。

任何帮助表示赞赏

4

1 回答 1

0

找到答案了,quote参数应该设置成quote="\""

myfiles = do.call(rbind, lapply(files, function(x) read.table(x, stringsAsFactors = FALSE, header = F, fill = T, sep=",", quote ="\"")))
于 2016-03-29T13:12:07.640 回答