[R] check whether connection can be opened

Michael Weylandt michael.weylandt at gmail.com
Wed Jul 18 16:18:48 CEST 2012


I think you'll need to roll your own using tryCatch() around open(). 

Michael

On Jul 18, 2012, at 5:09 AM, Berry Boessenkool <berryboessenkool at hotmail.com> wrote:

> 
> 
> Hi all,
> 
> I'm working on a function that reads online data that is only available to certain IPs. It then writes a subset of the data into a file.
> So whenever I'm logged in elsewhere or am not connected to the internet, I get an error, and the function is terminated.
> I want it to rather print a message into the file.
> 
> Is there any way to test whether a connection can be opened?
> Analogous to isOpen something like canOpen...
> Or would I want to look into the error handling options?
> 
> By the way, the data is the internet volume used so far, which I want to track regularly (on every R-Start via Rprofile).
> My brother (a computer schientist in progress) did not know a solution, so I set out to try this with R - which I got to work fine (except the above mentioned). 
> "R beats java", I told him, to which he responded nothing ;-)
> Isn't it amazing, what one can do with R?
> 
> Thanks ahead,
> Berry Boessenkool
> 
>                         
>    [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list