On 30/11/10 10:10:07, Baoqiang Cao wrote: > I'd like to download some data files from a remote server, the problem > here is that some of the files actually don't exist, which I don't > know before try. Just wondering if a function in R could tell me if a > file exists on a remote server?
Hi Baoqiang, try downloading the file with R's download.file() function. Then you should examine the returned value. Citing a part of ?download.file below: >> Value: >> An (invisible) integer code, ‘0’ for success and non-zero for >> failure. For the ‘"wget"’ and ‘"lynx"’ methods this is the status >> code returned by the external program. The ‘"internal"’ method can >> return ‘1’, but will in most cases throw an error. So if you call your download via v <- download.file(url, destfile, method="wget") and v is not equal to zero, then the file is likely to be non-existent (at least the download failed). Note: the method "internal" doesn't really change the value of v, I just tried that. With "wget" it returns "0" for success and "2048" (or some other value) for non-success. Regards, Georg. -- Research Assistant Otto-von-Guericke-Universität Magdeburg resea...@georgruss.de http://research.georgruss.de ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.