[R] TryCatch() with read.csv("http://...")

tom wright tom at maladmin.com
Wed Nov 23 17:59:21 CET 2005


How are you trying to break the loop?
The next statement should move to the next in the sequence (from the
Introduction To R manual)

On Wed, 2005-23-11 at 11:57 -0500, David L. Van Brunt, Ph.D. wrote:
> Hi, folks!
> 
> I'm trying to pull in data using read.csv("my URL goes here"), and it really
> works fantastically. Amazing to pull in live data right off the internet,
> into RAM, and get busy...
> 
> however...
> 
> occasionally there is a server problem, or the data are not up  yet, and
> instead of pushing through a nice CSV file, the server sends a 404 "Not
> Found" page...
> 
> Since the read is inside a "FOR" loop, (pulling in and analyzing different
> data each time) I've been trying to use TryCatch() to pull in the file if
> it's OK, but to jump out to the next iteration of the loop otherwise (using
> "next"). I don't want to exit the script, I just want to skip this iteration
> and move on. This seems like it should be obvious, but I've read through the
> ? files and tried everything my smooth little brain can come up with... no
> luck. I still end up jumping out of the entire script if I hit an error
> page.
> 
> Does anyone have some example syntax that I might examine or try out?
> 
> I'm feeling pretty thick here...
> 
> --
> ---------------------------------------
> David L. Van Brunt, Ph.D.
> mailto:dlvanbrunt at gmail.com
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list