更新时间:2022-03-02 10:20:06
对于引入显式错误处理的另一种方法,请考虑使用tryCatch
处理在您的read.table
中可能发生的其他不良情况.
For a different approach that introduces explicit error handling, think about a tryCatch
to handle anything else bad that might happen in your read.table
.
for (f in files) {
data <- tryCatch({
if (file.size(f) > 0){
read.table(f, header = F, sep=",")
}
}, error = function(err) {
# error handler picks up where error was generated
print(paste("Read.table didn't work!: ",err))
})
data$species <- strsplit(f, split = "c.txt")
DF <- rbind(DF, data)
}