Skip to content
Back to formatted view

Raw Message

Message-ID: <D5348801-EDBF-4195-83DA-840FEC544596@plessthan.com>
Date: 2009-05-11T15:57:28Z
From: Dennis Fisher
Subject: R errors when trying to read a file

Colleagues,

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

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