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




-- 
 The Wellcome Trust Sanger Institute is operated by Genome Research 

 Limited, a charity registered in England with number 1021457 and a 
 compa
ny registered in England with number 2742969, whose registered 
 office is 2
15 Euston Road, London, NW1 2BE. 



	[[alternative HTML version deleted]]


