New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
geocode.R: urlonly parameter does not get passed to single-pass function call via ldply #207
Comments
P.S.: This also applies to the force parameter. Therefore my code suggestion should be expanded like this: # geocode ply and out
if(output == "latlon" || output == "latlona" || output == "more"){
return(ldply(as.list(location), geocode, output = output, source = source, messaging = messaging, inject = inject, urlonly = urlonly, force = force))
} else { # output = all
return(llply(as.list(location), geocode, output = output, source = source, messaging = messaging, inject = inject, urlonly = urlonly, force = force))
} |
The same is true for other parameters as well which are currently missing from the ldply call, namely A reprex of the two parameters @janhkoch mentioned. library(ggmap)
#> Loading required package: ggplot2
#> Google Maps API Terms of Service: http://developers.google.com/maps/terms.
#> Please cite ggmap if you use it: see citation("ggmap") for details.
register_google(key = Sys.getenv("GOOGLE_GEOCODE_KEY"))
geocode("washington dc", urlonly = TRUE)
#> [1] "https://maps.googleapis.com/maps/api/geocode/json?address=washington%20dc&key=my_google_key" but with multiple locations places <- c("Houston, Texas", "Washington, DC")
geocode(places, urlonly = TRUE)
#> Source : https://maps.googleapis.com/maps/api/geocode/json?address=Houston%2C%20Texas&key=my_google_key
#> Source : https://maps.googleapis.com/maps/api/geocode/json?address=Washington%2C%20DC&key=my_google_key
#> lon lat
#> 1 -95.36980 29.76043
#> 2 -77.03687 38.90719 The same is true for the Single location geocode("washington dc", force = FALSE)
#> Source : https://maps.googleapis.com/maps/api/geocode/json?address=washington%20dc&key=my_google_key
#> lon lat
#> 1 -77.03687 38.90719 The second call is returned from the cache geocode("washington dc", force = FALSE)
#> lon lat
#> 1 -77.03687 38.90719 for multiple locations geocode(places, force = FALSE)
#> Source : https://maps.googleapis.com/maps/api/geocode/json?address=Houston%2C%20Texas&key=my_google_key
#> Source : https://maps.googleapis.com/maps/api/geocode/json?address=Washington%2C%20DC&key=my_google_key
#> lon lat
#> 1 -95.36980 29.76043
#> 2 -77.03687 38.90719 Created on 2018-03-26 by the reprex package (v0.2.0). Session infodevtools::session_info()
#> Session info -------------------------------------------------------------
#> setting value
#> version R version 3.4.4 (2018-03-15)
#> system x86_64, mingw32
#> ui RTerm
#> language en
#> collate German_Germany.1252
#> tz Europe/Berlin
#> date 2018-03-26
#> Packages -----------------------------------------------------------------
#> package * version date source
#> assertthat 0.2.0 2017-04-11 CRAN (R 3.4.2)
#> backports 1.1.2 2017-12-13 CRAN (R 3.4.3)
#> base * 3.4.4 2018-03-15 local
#> bindr 0.1.1 2018-03-13 CRAN (R 3.4.4)
#> bindrcpp * 0.2 2017-06-17 CRAN (R 3.4.0)
#> bitops 1.0-6 2013-08-17 CRAN (R 3.4.1)
#> colorspace 1.3-2 2016-12-14 CRAN (R 3.4.2)
#> compiler 3.4.4 2018-03-15 local
#> datasets * 3.4.4 2018-03-15 local
#> devtools 1.13.5 2018-02-18 CRAN (R 3.4.3)
#> digest 0.6.15 2018-01-28 CRAN (R 3.4.3)
#> dplyr 0.7.4 2017-09-28 CRAN (R 3.4.2)
#> evaluate 0.10.1 2017-06-24 CRAN (R 3.4.0)
#> ggmap * 2.7.900 2018-03-09 Github (dkahle/ggmap@d4f4aa3)
#> ggplot2 * 2.2.1 2016-12-30 CRAN (R 3.4.3)
#> glue 1.2.0.9000 2018-02-09 local
#> graphics * 3.4.4 2018-03-15 local
#> grDevices * 3.4.4 2018-03-15 local
#> grid 3.4.4 2018-03-15 local
#> gtable 0.2.0 2016-02-26 CRAN (R 3.4.2)
#> htmltools 0.3.6 2017-04-28 CRAN (R 3.4.0)
#> jpeg 0.1-8 2014-01-23 CRAN (R 3.4.1)
#> knitr 1.20 2018-02-20 CRAN (R 3.4.3)
#> lazyeval 0.2.1 2017-10-29 CRAN (R 3.4.2)
#> magrittr 1.5 2014-11-22 CRAN (R 3.4.2)
#> memoise 1.1.0 2018-01-08 Github (hadley/memoise@611cfad)
#> methods * 3.4.4 2018-03-15 local
#> munsell 0.4.3 2016-02-13 CRAN (R 3.4.2)
#> pillar 1.2.1 2018-02-27 CRAN (R 3.4.3)
#> pkgconfig 2.0.1 2017-03-21 CRAN (R 3.4.0)
#> plyr 1.8.4 2016-06-08 CRAN (R 3.4.2)
#> png 0.1-7 2013-12-03 CRAN (R 3.4.1)
#> R6 2.2.2 2017-06-17 CRAN (R 3.4.0)
#> Rcpp 0.12.16 2018-03-13 CRAN (R 3.4.4)
#> RgoogleMaps 1.4.1 2016-09-18 CRAN (R 3.4.2)
#> rjson 0.2.15 2014-11-03 CRAN (R 3.4.1)
#> rlang 0.2.0.9000 2018-03-07 Github (tidyverse/rlang@d2ed2cf)
#> rmarkdown 1.9.2 2018-03-05 Github (rstudio/rmarkdown@9313596)
#> rprojroot 1.3-2 2018-01-03 CRAN (R 3.4.3)
#> scales 0.5.0.9000 2017-09-07 Github (hadley/scales@d767915)
#> stats * 3.4.4 2018-03-15 local
#> stringi 1.1.7 2018-03-12 CRAN (R 3.4.4)
#> stringr 1.3.0 2018-02-19 CRAN (R 3.4.3)
#> tibble 1.4.2 2018-01-22 CRAN (R 3.4.3)
#> tools 3.4.4 2018-03-15 local
#> utils * 3.4.4 2018-03-15 local
#> withr 2.1.2 2018-03-15 CRAN (R 3.4.4)
#> yaml 2.1.18 2018-03-08 CRAN (R 3.4.4) |
Sorry for returning to this so late - thank you very much for fixing this! |
Sorry for omitting a reproducible example, but I think my problem should be understandable from the code below.
I was wondering why a geocode run for many locations and "urlonly = TRUE" was querying Google anyway. To my understanding, it should not. I found out that the reason for this behavior is in lines 122 and 124 of geocode.R. They are currently:
The ldply call omits the urlonly parameter. Thus, even if the "top-level function" function is called with "urlonly = TRUE", the single-item function call queries the data source.
If I do not understand the urlonly parameter completely wring, I think that section should be:
The text was updated successfully, but these errors were encountered: