我写了一个代码,将excel文件合并到一个大数据框中。代码在少量测试文件(< = 200)下工作正常,但是现在当我在实际文件(~2500)上运行代码时,它给出了以下错误。
fix.by(by.y,y)出错:'by'必须指定唯一有效的列
library(rJava)
library (XLConnect)
data.files = list.files(pattern = "*.xls")
df = readWorksheetFromFile(file=data.files[1], sheet=1, check.names=F) # Read the first file
# Loop through the remaining files and merge them to the existing data frame
for (file in data.files[-1]) {
newFile = readWorksheetFromFile(file=file, sheet=1, check.names=F)
df = merge(df, newFile, all = TRUE, check.names=F)
}
write.csv(df, file="Collated_Raw_Files.csv")
我是 R 的新手。任何意见都将不胜感激。