【问题标题】:Error in using the googlway package in R在 R 中使用 googlway 包时出错
【发布时间】:2017-06-10 12:58:15
【问题描述】:

您好,我在 R 中使用 googlway 包时遇到问题。更具体地说,它涉及 google_distance 函数和交通模型的选择。 当我执行我的脚本时:

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)

我收到以下消息:Error in match.arg(traffic_model) : 'arg' should be one of

当我删除“traffic_model='pessimistic'”行时,我没有任何问题。

有什么想法吗?

【问题讨论】:

    标签: r googleway


    【解决方案1】:

    您已找到a bug with that particular argument。我已经在开发版本中修复了这个问题,你可以通过这样做来获得

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

    然后就可以了

    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"
    

    【讨论】:

    • 非常感谢您的更新。效果很好!
    • 我回来是因为还有问题。我没有发现 "optimistic" 、 "best_guess" 和 "pessimistic" 选项之间的结果有任何差异。因此,我无法找到谷歌地图页面上显示的相应结果。
    猜你喜欢
    • 2012-06-12
    • 2016-06-20
    • 1970-01-01
    • 1970-01-01
    • 2023-01-27
    • 2015-08-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多