Dear All, To check if an url exists, I can use try(). This works, as I expected, if I do it directly, as in the first part of the following example, but I could not find a way to do it from within a function, as in the second part.
Where could I find information on how to do this? Thanks, Heinz ## set nonexisting url url.string <- 'http://www.google.at/nonexist.html' ## first part 1 # to start with defined .Last.value try(con.url <- url(url.string, open='rb')) class.try.res <- class(.Last.value) try.error <- class.try.res== 'try-error' print(try.error) # TRUE try(close(con.url)) ## try() within a function url.error <- function(url.string) { 1 # to start with defined .Last.value try(con.url <- url(url.string, open='rb')) class.try.res <- class(.Last.value) try.error <- class.try.res== 'try-error' print(try.error) try(close(con.url)) invisible(try.error) } ## call the function url.error(url.string) # result -> FALSE ______________________________________________ [email protected] 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.
