I have many URLs which I import their text in R. I use this code:
setNames(lapply(1:1000, function(x) gettxt(get(paste0("url", x)))), paste0("url", 1:1000, "_txt")) %>%
list2env(envir = globalenv())
However, some URLs can not import and show this error:
Error in file(con, "r") : cannot open the connection In addition: Warning message: In file(con, "r") : InternetOpenUrl failed: 'A connection with the server could not be established'
So, my code doesn't run and doesn't import any text from any URL. How can I recognize wrong URLs and skip them in other to import correct URLs?