2

Hello I have a problem using the googlway package in R. More specifically, it concerns the google_distance function and the selection of the trafic model. When I execute my script:

x <- as.POSIXct("2017-02-2 00:00:00", tz = "Europe/Paris")
google_distance(origins = list(c(48.93, 2.175)),
                   destinations =list(c(48.95, 2.19)),
                   mode="driving",
                   departure_time=x,
                   traffic_model='pessimistic',
                   key = key,
                   simplify = T)

I receive the following message: Error in match.arg(traffic_model) : 'arg' should be one of

When I drop the line "traffic_model='pessimistic'" I don't have any problem.

Any idea?

jean
  • 31
  • 1

1 Answers1

0

You've found a bug with that particular argument. I've fixed this in the development version which you can get by doing

library(devtools)
devtools::install_github("SymbolixAU/googleway")

And then it will work

library(googleway)

x <- as.POSIXct("2017-02-11 00:00:00", tz = "Europe/Paris")
key <- "your_api_key"
google_distance(origins = list(c(48.93, 2.175)),
                                destinations =list(c(48.95, 2.19)),
                                mode="driving",
                                departure_time=x,
                                traffic_model='pessimistic',
                                key = key,
                                simplify = T)


# $destination_addresses
# [1] "34 Rue Calmette et Guérin, 78500 Sartrouville, France"
# 
# $origin_addresses
# [1] "131 Rue Lavoisier, 78800 Houilles, France"
# 
# $rows
# elements
# 1 3.9 km, 3928, 10 mins, 618, 10 mins, 598, OK
# 
# $status
# [1] "OK"
SymbolixAU
  • 25,502
  • 4
  • 67
  • 139
  • Thank you very much for this update. It works perfectly! – jean Feb 11 '17 at 11:28
  • I come back because there is still a problem. I don't find any difference in results between the "optimistic" , "best_guess"and the "pessimistic" options. Consequently I can't find back the corresponding results appearing on the google map page. – jean Feb 11 '17 at 11:57