0

I'm using R to obtain json files from a website. In particular, I'm using the fromJSON function of the RJSONIO package. I'm trying to get json files from 50,000 website links. However, some of them might not be valid API links. Right now, I'm using for loop to get the json files. However, each time I encounter an invalid link, the whole program comes to a halt.

How can I just pass to the next iteration if I encounter invalid API links?

Ana
  • 15
  • 3
  • 2
    Use `try` or `tryCatch` around the `fromJSON` call (prbly best to write a wrapper function for `fromJSON` that handles this case well). – hrbrmstr Aug 06 '15 at 02:21

1 Answers1

0

It turns out that using tryCatch at every iteration will do the job. If it is an invalid URL, some warning messages will be posted but the iteration will continue.

Ana
  • 15
  • 3