2

I have a table of origin/destination pairs (lat-long coordinates). I'm using the R library gmapsdistance and mapply to loop over the table calling the API for each row. (The primary reason for this approach is that each row is a unique combination of origin, destination, and departure time, but gmapsdistance does not accept a vector of departure times.)

The problem is that I'm getting random, non-reproducible errors. I'll run the first 2000 rows and something will crash. I will back up and run the first 1000 and then the second 1000 and get no error.

As a result, I'm unable to provide a reproducible example. (If I could, I'd like to think I would have solved this by now.) Here is my mapply call:

result <- mapply(
        gmapsdistance,
        origin = to_skim$coords_orig,
        destination = to_skim$coords_dest,
        combinations = "pairwise",
        key = api_key,
        mode = mode,
        departure = to_skim$departure_secs
      )

The error messages themselves are not constant. I've seen ERROR : replacement has length zero but also:

AttValue: " or ' expected
attributes construct error
Couldn't find end of Start Tag html line 2
Extra content at the end of the document

The key is that I can re-run the exact same call and get a successful result. Thanks for any and all advice!

Kyle Ward
  • 889
  • 1
  • 8
  • 18

0 Answers0