[R] Test internet presence

Gregor Gorjanc gregor.gorjanc at bfro.uni-lj.si
Mon Sep 11 13:47:24 CEST 2006

Gregor Gorjanc wrote:
> Gregor Gorjanc wrote:
>> Hello useRs!
>> I have a small package and I need internet access for examples. Of
>> course it works fine when I have internet access, but not otherwise. I
>> remember I saw a way to test availability of internet access, but I can
>> not find it now in archives. Can anyone here help me?
>> David Barron wrote:
>>> I means non-zero, not non-negative.
>> ...
>> Thanks. download.file() is fine!
> Thinking a bit more, download.file() is not really general as I need to
> specify an url and it might happen that I have internet connection, but
> server that provides url is down. I am to picky on this?

Additionally, download.file throws an error if url is not available i.e.
if I do not have internet access. I have used the following example:

                 destfile=tempfile()) == 0) {

unpluged the net cable and got the following message during R CMD check
(in examples part)

trying URL 'http://www.r-project.org/index.html'
Warning: unable to resolve 'www.r-project.org'.
Error in download.file(url = "http://www.r-project.org/index.html",
destfile = tempfile()) :
        cannot open URL 'http://www.r-project.org/index.html'
Execution halted

It seems that 'internal' method was used (I use R 2.3.1 under Linux) as
indicated in help page of download.file. I could use wget or lynx
methods, but these two must be available, so this is not really
portable. Are there any other options for testing internet access? I am
thinking that this might be more relevant for R-devel. I will wait a bit
before moving there.

Lep pozdrav / With regards,
    Gregor Gorjanc

University of Ljubljana     PhD student
Biotechnical Faculty
Zootechnical Department     URI: http://www.bfro.uni-lj.si/MR/ggorjan
Groblje 3                   mail: gregor.gorjanc <at> bfro.uni-lj.si

SI-1230 Domzale             tel: +386 (0)1 72 17 861
Slovenia, Europe            fax: +386 (0)1 72 17 888

"One must learn by doing the thing; for though you think you know it,
 you have no certainty until you try." Sophocles ~ 450 B.C.

More information about the R-help mailing list