mapdist returns correct results but in the wrong order
- Dominant language
- R
- Stars
- 778
- Forks
- 234
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I've just encountered a strange problem with the results from mapdist. For my set of addresses, the calculated distances are correct but their positions are swapped in the data frame containing the results. For example, 13144m, which is in row 2, should be in row 6.
I would be grateful if you could give me some hint - whether it is only my data, my machine, or maybe a more general problem (package bug or Google API).
Thanks
Bartek
## Reproducible Example
``` r
library("ggmap")
#> Warning: Paket 'ggmap' wurde unter R Version 3.5.2 erstellt
#> Lade nötiges Paket: ggplot2
#> Warning: Paket 'ggplot2' wurde unter R Version 3.5.3 erstellt
#> Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
#> Please cite ggmap if you use it! See citation("ggmap") for details.
addresses <- data.frame(from = c("Hainbachweg 5, 6450 Sölden",
"Gaislachkogelbahn Talstation, Dorfstraße, Sölden",
"Hotel Garni Hainbacherhof, Hainbachweg 5, 6450 Sölden",
"Rettenbachstraße 4, 6450 Sölden",
"Dorfstraße 50, 6450",
"Längenfeld"),
to = c("Gaislachkogelbahn Talstation, Dorfstraße, Sölden",
"Hotel Garni Hainbacherhof, Hainbachweg 5, 6450 Sölden",
"Sölden",
"Gaislachkogelbahn Talstation, Dorfstraße, Sölden",
"Giggijochbahn Sölden, Giggijochstraße, Sölden",
"Giggijochbahn Sölden, Giggijochstraße, Sölden"))
addresses <- as.data.frame(lapply(addresses, function(x) as.character(x)), stringsAsFactors = F)
addresses
#> from
#> 1 Hainbachweg 5, 6450 Sölden
#> 2 Gaislachkogelbahn Talstation, Dorfstraße, Sölden
#> 3 Hotel Garni Hainbacherhof, Hainbachweg 5, 6450 Sölden
#> 4 Rettenbachstraße 4, 6450 Sölden
#> 5 Dorfstraße 50, 6450
#> 6 Längenfeld
#> to
#> 1 Gaislachkogelbahn Talstation, Dorfstraße, Sölden
#> 2 Hotel Garni Hainbacherhof, Hainbachweg 5, 6450 Sölden
#> 3 Sölden
#> 4 Gaislachkogelbahn Talstation, Dorfstraße, Sölden
#> 5 Giggijochbahn Sölden, Giggijochstraße, Sölden
#> 6 Giggijochbahn Sölden, Giggijochstraße, Sölden
distances <- mapdist(addresses$from, addresses$to, mode = "driving")
#> Source : https://maps.googleapis.com/maps/api/distancematrix/json?origins=Dorfstra%C3%9Fe+50,+6450&destinations=Giggijochbahn+S%C3%B6lden,+Giggijochstra%C3%9Fe,+S%C3%B6lden&key=xxx-LYmo6Lw7vHfFPtsA1hRuJoYDLM&mode=driving
#> Source : https://maps.googleapis.com/maps/api/distancematrix/json?origins=Gaislachkogelbahn+Talstation,+Dorfstra%C3%9Fe,+S%C3%B6lden&destinations=Hotel+Garni+Hainbacherhof,+Hainbachweg+5,+6450+S%C3%B6lden&key=xxx-LYmo6Lw7vHfFPtsA1hRuJoYDLM&mode=driving
#> Source : https://maps.googleapis.com/maps/api/distancematrix/json?origins=Hainbachweg+5,+6450+S%C3%B6lden&destinations=Gaislachkogelbahn+Talstation,+Dorfstra%C3%9Fe,+S%C3%B6lden&key=xxx-LYmo6Lw7vHfFPtsA1hRuJoYDLM&mode=driving
#> Source : https://maps.googleapis.com/maps/api/distancematrix/json?origins=Hotel+Garni+Hainbacherhof,+Hainbachweg+5,+6450+S%C3%B6lden&destinations=S%C3%B6lden&key=xxx-LYmo6Lw7vHfFPtsA1hRuJoYDLM&mode=driving
#> Source : https://maps.googleapis.com/maps/api/distancematrix/json?origins=L%C3%A4ngenfeld&destinations=Giggijochbahn+S%C3%B6lden,+Giggijochstra%C3%9Fe,+S%C3%B6lden&key=xxx-LYmo6Lw7vHfFPtsA1hRuJoYDLM&mode=driving
#> Source : https://maps.googleapis.com/maps/api/distancematrix/json?origins=Rettenbachstra%C3%9Fe+4,+6450+S%C3%B6lden&destinations=Gaislachkogelbahn+Talstation,+Dorfstra%C3%9Fe,+S%C3%B6lden&key=xxx-LYmo6Lw7vHfFPtsA1hRuJoYDLM&mode=driving
distances
#> # A tibble: 6 x 9
#> from to m km miles seconds minutes hours mode
#>
#> 1 Hainbachweg ~ Gaislachkog~ 1113 1.11 0.692 165 2.75 0.0458 driv~
#> 2 Gaislachkoge~ Hotel Garni~ 13144 13.1 8.17 903 15.0 0.251 driv~
#> 3 Hotel Garni ~ Sölden 1300 1.3 0.808 195 3.25 0.0542 driv~
#> 4 Rettenbachst~ Gaislachkog~ 1947 1.95 1.21 265 4.42 0.0736 driv~
#> 5 Dorfstraße 5~ Giggijochba~ 1945 1.94 1.21 262 4.37 0.0728 driv~
#> 6 Längenfeld Giggijochba~ 7642 7.64 4.75 1326 22.1 0.368 driv~
```
Created on 2019-04-24 by the [reprex package](https://reprex.tidyverse.org) (v0.2.1)
Session info
``` r
devtools::session_info()
#> - Session info ----------------------------------------------------------
#> setting value
#> version R version 3.5.0 (2018-04-23)
#> os Windows 7 x64 SP 1
#> system x86_64, mingw32
#> ui RTerm
#> language (EN)
#> collate German_Austria.1252
#> ctype German_Austria.1252
#> tz Europe/Berlin
#> date 2019-04-24
#>
#> - Packages --------------------------------------------------------------
#> package * version date lib source
#> assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.5.3)
#> backports 1.1.4 2019-04-10 [1] CRAN (R 3.5.3)
#> bitops 1.0-6 2013-08-17 [1] CRAN (R 3.5.0)
#> callr 3.2.0 2019-03-15 [1] CRAN (R 3.5.3)
#> cli 1.1.0 2019-03-19 [1] CRAN (R 3.5.3)
#> colorspace 1.4-1 2019-03-18 [1] CRAN (R 3.5.3)
#> crayon 1.3.4 2017-09-16 [1] CRAN (R 3.5.0)
#> curl 3.3 2019-01-10 [1] CRAN (R 3.5.2)
#> desc 1.2.0 2018-05-01 [1] CRAN (R 3.5.2)
#> devtools 2.0.2 2019-04-08 [1] CRAN (R 3.5.3)
#> digest 0.6.18 2018-10-10 [1] CRAN (R 3.5.2)
#> dplyr 0.8.0.1 2019-02-15 [1] CRAN (R 3.5.2)
#> evaluate 0.13 2019-02-12 [1] CRAN (R 3.5.3)
#> fansi 0.4.0 2018-10-05 [1] CRAN (R 3.5.2)
#> fs 1.2.7 2019-03-19 [1] CRAN (R 3.5.3)
#> ggmap * 3.0.0 2019-02-05 [1] CRAN (R 3.5.2)
#> ggplot2 * 3.1.1 2019-04-07 [1] CRAN (R 3.5.3)
#> glue 1.3.1 2019-03-12 [1] CRAN (R 3.5.3)
#> gtable 0.3.0 2019-03-25 [1] CRAN (R 3.5.3)
#> highr 0.8 2019-03-20 [1] CRAN (R 3.5.3)
#> htmltools 0.3.6 2017-04-28 [1] CRAN (R 3.5.0)
#> httr 1.4.0 2018-12-11 [1] CRAN (R 3.5.2)
#> jpeg 0.1-8 2014-01-23 [1] CRAN (R 3.5.0)
#> jsonlite 1.6 2018-12-07 [1] CRAN (R 3.5.2)
#> knitr 1.22 2019-03-08 [1] CRAN (R 3.5.3)
#> lazyeval 0.2.2 2019-03-15 [1] CRAN (R 3.5.3)
#> magrittr 1.5 2014-11-22 [1] CRAN (R 3.5.0)
#> memoise 1.1.0 2017-04-21 [1] CRAN (R 3.5.0)
#> munsell 0.5.0 2018-06-12 [1] CRAN (R 3.5.0)
#> pillar 1.3.1 2018-12-15 [1] CRAN (R 3.5.2)
#> pkgbuild 1.0.3 2019-03-20 [1] CRAN (R 3.5.3)
#> pkgconfig 2.0.2 2018-08-16 [1] CRAN (R 3.5.2)
#> pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.5.2)
#> plyr 1.8.4 2016-06-08 [1] CRAN (R 3.5.0)
#> png 0.1-7 2013-12-03 [1] CRAN (R 3.5.2)
#> prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.5.2)
#> processx 3.3.0 2019-03-10 [1] CRAN (R 3.5.3)
#> ps 1.3.0 2018-12-21 [1] CRAN (R 3.5.2)
#> purrr 0.3.2 2019-03-15 [1] CRAN (R 3.5.3)
#> R6 2.4.0 2019-02-14 [1] CRAN (R 3.5.3)
#> Rcpp 1.0.1 2019-03-17 [1] CRAN (R 3.5.3)
#> remotes 2.0.4 2019-04-10 [1] CRAN (R 3.5.3)
#> RgoogleMaps 1.4.3 2018-11-07 [1] CRAN (R 3.5.2)
#> rjson 0.2.15 2014-11-03 [1] CRAN (R 3.5.0)
#> rlang 0.3.4 2019-04-07 [1] CRAN (R 3.5.3)
#> rmarkdown 1.12 2019-03-14 [1] CRAN (R 3.5.3)
#> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.5.0)
#> scales 1.0.0 2018-08-09 [1] CRAN (R 3.5.2)
#> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.5.2)
#> stringi 1.4.3 2019-03-12 [1] CRAN (R 3.5.3)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 3.5.2)
#> tibble 2.1.1 2019-03-16 [1] CRAN (R 3.5.3)
#> tidyr 0.8.3 2019-03-01 [1] CRAN (R 3.5.3)
#> tidyselect 0.2.5 2018-10-11 [1] CRAN (R 3.5.1)
#> usethis 1.5.0 2019-04-07 [1] CRAN (R 3.5.3)
#> utf8 1.1.4 2018-05-24 [1] CRAN (R 3.5.0)
#> withr 2.1.2 2018-03-15 [1] CRAN (R 3.5.0)
#> xfun 0.6 2019-04-02 [1] CRAN (R 3.5.3)
#> yaml 2.2.0 2018-07-25 [1] CRAN (R 3.5.2)
#>
#> [1] C:/Users/c8451181/Documents/R/win-library/3.5
#> [2] C:/Program Files/R/R-3.5.0/library
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.