Skip to content
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

mutate_geocode errors out with output = "more" #201

Closed
dpprdan opened this issue Feb 24, 2018 · 3 comments
Closed

mutate_geocode errors out with output = "more" #201

dpprdan opened this issue Feb 24, 2018 · 3 comments
Labels

Comments

@dpprdan
Copy link

dpprdan commented Feb 24, 2018

mutate_geocode does not work with output = "latlona" or output = "more" (anymore - I am pretty sure this used to work).

df <- data.frame(
  address = c("1600 Pennsylvania Avenue, Washington DC", "", "houston texas"),
  stringsAsFactors = FALSE
)

suppressPackageStartupMessages({
  library(dplyr)
  library(ggmap)
  })


df %>% mutate_geocode(address, output = "latlon")
#> Source : https://maps.googleapis.com/maps/api/geocode/json?address=1600%20Pennsylvania%20Avenue%2C%20Washington%20DC
#> Warning: geocode failed with status OVER_QUERY_LIMIT, location = "1600
#> Pennsylvania Avenue, Washington DC"
#> Source : https://maps.googleapis.com/maps/api/geocode/json?address=houston%20texas
#> Warning: geocode failed with status OVER_QUERY_LIMIT, location = "houston
#> texas"
#>                                   address lon lat
#> 1 1600 Pennsylvania Avenue, Washington DC  NA  NA
#> 2                                          NA  NA
#> 3                           houston texas  NA  NA

df %>% mutate_geocode(address, output = "latlona")
#> Source : https://maps.googleapis.com/maps/api/geocode/json?address=1600%20Pennsylvania%20Avenue%2C%20Washington%20DC
#> Source : https://maps.googleapis.com/maps/api/geocode/json?address=houston%20texas
#> Error in list_to_dataframe(res, attr(.data, "split_labels"), .id, id_as_factor): Results must be all atomic, or all data frames

df %>% mutate_geocode(address, output = "more")
#> Source : https://maps.googleapis.com/maps/api/geocode/json?address=1600%20Pennsylvania%20Avenue%2C%20Washington%20DC
#> Source : https://maps.googleapis.com/maps/api/geocode/json?address=houston%20texas
#> Error in list_to_dataframe(res, attr(.data, "split_labels"), .id, id_as_factor): Results must be all atomic, or all data frames

Created on 2018-02-24 by the reprex package (v0.2.0).

Session info
devtools::session_info()
#> Session info -------------------------------------------------------------
#>  setting  value                       
#>  version  R version 3.4.3 (2017-11-30)
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language EN                          
#>  collate  German_Germany.1252         
#>  tz       Europe/Berlin               
#>  date     2018-02-24
#> Packages -----------------------------------------------------------------
#>  package     * version    date       source                          
#>  assertthat    0.2.0      2017-04-11 CRAN (R 3.4.0)                  
#>  backports     1.1.2      2017-12-13 CRAN (R 3.4.3)                  
#>  base        * 3.4.3      2017-12-06 local                           
#>  bindr         0.1        2016-11-13 CRAN (R 3.4.0)                  
#>  bindrcpp    * 0.2        2017-06-17 CRAN (R 3.4.1)                  
#>  bitops        1.0-6      2013-08-17 CRAN (R 3.4.1)                  
#>  colorspace    1.3-2      2016-12-14 CRAN (R 3.4.3)                  
#>  compiler      3.4.3      2017-12-06 local                           
#>  datasets    * 3.4.3      2017-12-06 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.1)                  
#>  ggmap       * 2.7.900    2018-02-24 Github (dkahle/ggmap@d4f4aa3)   
#>  ggplot2     * 2.2.1      2016-12-30 CRAN (R 3.4.3)                  
#>  glue          1.2.0      2017-10-29 CRAN (R 3.4.3)                  
#>  graphics    * 3.4.3      2017-12-06 local                           
#>  grDevices   * 3.4.3      2017-12-06 local                           
#>  grid          3.4.3      2017-12-06 local                           
#>  gtable        0.2.0      2016-02-26 CRAN (R 3.4.3)                  
#>  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.3)                  
#>  memoise       1.1.0      2017-04-21 CRAN (R 3.4.0)                  
#>  methods     * 3.4.3      2017-12-06 local                           
#>  munsell       0.4.3      2016-02-13 CRAN (R 3.4.3)                  
#>  pillar        1.1.0      2018-01-14 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.3)                  
#>  png           0.1-7      2013-12-03 CRAN (R 3.4.1)                  
#>  R6            2.2.2      2017-06-17 CRAN (R 3.4.1)                  
#>  Rcpp          0.12.15    2018-01-20 CRAN (R 3.4.3)                  
#>  RgoogleMaps   1.4.1      2016-09-18 CRAN (R 3.4.3)                  
#>  rjson         0.2.15     2014-11-03 CRAN (R 3.4.1)                  
#>  rlang         0.2.0.9000 2018-02-24 Github (tidyverse/rlang@3143f00)
#>  rmarkdown     1.8        2017-11-17 CRAN (R 3.4.3)                  
#>  rprojroot     1.3-2      2018-01-03 CRAN (R 3.4.2)                  
#>  scales        0.5.0      2017-08-24 CRAN (R 3.4.1)                  
#>  stats       * 3.4.3      2017-12-06 local                           
#>  stringi       1.1.6      2017-11-17 CRAN (R 3.4.2)                  
#>  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.3      2017-12-06 local                           
#>  utils       * 3.4.3      2017-12-06 local                           
#>  withr         2.1.1.9000 2018-02-24 Github (r-lib/withr@5d05571)    
#>  yaml          2.1.16     2017-12-12 CRAN (R 3.4.3)
@sysilviakim
Copy link

I can no longer reproduce the errors above as of commit `fc5e0fd' today. However, the option "all" does give me an error in case of row > 1 dataframes.

## This works:
data.frame(
  address = c("1200 E California Blvd, Pasadena, CA 91125"), 
  stringsAsFactors = FALSE
) %>% 
    mutate_geocode(address, output = "all")

## This also works:
data.frame(
  address = rep("1200 E California Blvd, Pasadena, CA 91125", 2), 
  stringsAsFactors = FALSE
) %>% 
    mutate_geocode(address, output = "latlon")

## This breaks with message Error in cbind_all(x) : Argument 2 must be length 2, not 1
data.frame(
  address = rep("1200 E California Blvd, Pasadena, CA 91125", 2), 
  stringsAsFactors = FALSE
) %>% 
    mutate_geocode(address, output = "all")

I guess I don't really need to resort to output = "all" but thought this may help some future users.

@dkahle
Copy link
Owner

dkahle commented Jan 31, 2019

Hi @sysilviakim, I assume you're looking to include output as a list-column? I'm not surprised that's not working, but it certainly makes sense for future releases. I'll make a note for the next release, thanks!

@dpprdan
Copy link
Author

dpprdan commented Feb 4, 2019

I am closing this, since the original issue is fixed. I moved the mutate_geocode(output = "all") list-column issue to #263.

@dpprdan dpprdan closed this as completed Feb 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants