Hi,
I'm using read.table in a loop, to read in multiple files. The problem
is that when a file is missing there is an error message and the loop is
broken; what I'd like to do is to test for the error and simply do
"next" instead of breaking the loop. Anybody knows how to do that?
Example:
filelist <- c("file1.txt", "file2.txt", "file3.txt")
for (i in 1:3) {
if (read.table(filelist[i]) == ERROR LOADING FILE) {
# this is where I do not know how to write the condition
print(paste("error opening file ", filelist[i], sep=""))
next
} else {
tmp <- read.table(filelist[i])
}
}
Cheers,
Stephane