R code

R code for the function and it's use. 

Unfortunately after a number of iterations, the loop produces an error. I think this is because the Google Maps API kick me out after a while. Interestingly, there is no pattern, so it doesn't happen every 10 iterations or so. 

A possible solution would be to include a while-loop that starts the loop over the function from the point where it left of after an error message. I don't know how to do this however.