Re: [R] About How to check if a html directory exists

From: Jerome Asselin <>
Date: Mon, 25 Apr 2011 18:31:54 -0400

On Mon, 2011-04-25 at 12:52 -0500, Wendy Han wrote:
> I want to let R automatically download available files from a website in
> certain folders. Since the files I need, if exist, are in a certain
> directory, I used download.file() function with a predesigned directory.
> However, some of the folders do not have the file I want. When this occurs,
> my program returns error and terminates. So I wonder if there is any way
> that I can check if a directory exists before downloading that file. I
> appreciate your help!

You could use the try() command to catch the download.file() error and, if there is one, handle it accordingly.

See help(try)

Jerome mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Mon 25 Apr 2011 - 22:33:41 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 25 Apr 2011 - 22:50:33 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive