Skip to content

How to detect whether a file exists or not?

4 messages · Francisco J Molina, Dirk Eddelbuettel, Roger D. Peng +1 more

#
I would like my program to load variables x,y,x from a file 'myFile.r' but
if this file does not exist, I want my program to create/initialize x,y,z.

Does anyone know how to do this?

Thank you very much.

Francisco J. Molina
#
On Wed, Feb 11, 2004 at 07:22:00PM -0800, Francisco J Molina wrote:
?file.info			# as help.search("file") would have revealed

Hth, Dirk
#
Even better, file.exists().

-roger
Dirk Eddelbuettel wrote:
#
?file.exists