2

Executing the following code using the purrr::map_dfr() function sometimes limits the number of API times per second.

data.frame(location = c("sapporo", "aomori", "sendai", "morioka", "yamagata", "iwate")) %>%
  purrr::map_dfr(.f = function(x) ggmap::geocode(as.character(x)))

Warning message: geocode failed with status OVER_QUERY_LIMIT, location = "aomori"

I'd like to put something like sys.sleep (1), but how do I do it?

ogw
  • 353
  • 1
  • 2
  • 13
  • 1
    Maybe see [here](https://stackoverflow.com/questions/36175529/getting-over-query-limit-after-one-request-with-geocode) for how to use an API key with `ggmap`. This may fix your issue entirely. – Davis Vaughan Nov 26 '17 at 14:47

1 Answers1

0

Great question! Within the function call system('sleep 10')

geoc <- function(x) {
gc <-ggmap::geocode(as.character(x))
system('sleep 5') # sleep 5 seconds
return(gc)
}
data.frame(location = c("sapporo", "aomori", "sendai", "morioka", "yamagata", 
"iwate")) %>%
 purrr::map_df(., geoc)