Re: [R] Loop for readLines(URL[i]) fails when URL returns Error 404

2012-08-22 Thread Noia Raindrops
Hello, For example: url <- c("http://www.example.com";, "http://www.example5.com";) res <- vector("list", length(url)) for (i in 1:length(url)) res[[i]] <- try(readLines(url[i]), silent = TRUE) res[[2]] ## [1] "Error in file(con, \"r\") : cannot open the connection\n" ## attr(,"class") ## [1] "tr

[R] Loop for readLines(URL[i]) fails when URL returns Error 404

2012-08-22 Thread Shelby McIntyre
I have a loop over readLines(URL[i]) which works fine until it hits a bad URL (e.g., a URL that returns a 404 Error). How can I handle this with a test for this error condition. I read the tryCatch( … ) description but can't figure out how to apply it here. Perhaps there is something else that