Skip to content
Prev 179965 / 398506 Next

R errors when trying to read a file

On Mon, 11 May 2009, Dennis Fisher wrote:

            
It is possible.  But so are a lot of other things, and your pretest is 
just not enough -- for example another process might have the file 
open for exclusive access (quite common in the Windows world) in which 
case it exists but you cannot open it for reading.

There is only one sure way to find out if you can read a file, and 
that is to try to read it.  So I'd simply use try() or tryCatch() on 
the readLines call.