[R] R errors when trying to read a file

Dennis Fisher fisher at plessthan.com
Mon May 11 17:57:28 CEST 2009


I have encountered a problem in version 2.9 of R, running in both  
Vista and OS X.  My code is quite lengthy but the critical line is:
	if (file.exists(FILENAME))	readLines(FILENAME))

This triggers the error:
	Error in file(con, "r") : cannot open the connection
	Calls: readLines -> file
	Execution halted

The file that it is reading is being created on the fly, then  
eventually deleted.  The conditional was used to ensure that the  
readLines command would be executed only when the file existed.

Is it possible that the file is deleted AFTER the conditional is  
evaluated but before the readLines command is executed?  If so, is  
there any means to prevent an error condition?

Any help will be greatly appreciated.  Thanks.


Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-415-564-2220

More information about the R-help mailing list