From 4a37cf02913931a2692b33dfde1f7f9a9c61f275 Mon Sep 17 00:00:00 2001 From: Daniel Possenriede Date: Thu, 28 Oct 2021 17:22:09 +0200 Subject: [PATCH 1/2] use quoted default values to fix memoise --- R/geo.R | 2 +- R/geocode.R | 2 +- R/geocode_combine.R | 2 +- R/reverse_geo.R | 2 +- R/reverse_geocode.R | 2 +- man/geo.Rd | 4 ++-- man/geocode.Rd | 4 ++-- man/geocode_combine.Rd | 4 ++-- man/reverse_geo.Rd | 2 +- man/reverse_geocode.Rd | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/R/geo.R b/R/geo.R index 1dc1eb1b..841ebe55 100644 --- a/R/geo.R +++ b/R/geo.R @@ -147,7 +147,7 @@ progress_geo <- function(pb = NULL, ...) { #' @export geo <- function(address = NULL, street = NULL, city = NULL, county = NULL, state = NULL, postalcode = NULL, country = NULL, - method = 'osm', cascade_order = c('census', 'osm'), lat = lat, long = long, limit = 1, + method = 'osm', cascade_order = c('census', 'osm'), lat = 'lat', long = 'long', limit = 1, full_results = FALSE, mode = '', unique_only = FALSE, return_addresses = TRUE, min_time = NULL, progress_bar = show_progress_bar(), quiet = getOption("tidygeocoder.quiet", FALSE), api_url = NULL, timeout = 20, flatten = TRUE, batch_limit = NULL, batch_limit_error = TRUE, diff --git a/R/geocode.R b/R/geocode.R index f3afe872..a480bd55 100644 --- a/R/geocode.R +++ b/R/geocode.R @@ -59,7 +59,7 @@ #' @export geocode <- function(.tbl, address = NULL, street = NULL, city = NULL, county = NULL, state = NULL, postalcode = NULL, country = NULL, - lat = lat, long = long, return_input = TRUE, limit = 1, return_addresses = NULL, unique_only = FALSE, ...) { + lat = 'lat', long = 'long', return_input = TRUE, limit = 1, return_addresses = NULL, unique_only = FALSE, ...) { # Non-standard evaluation -------------------------------------------------------------- # Quote unquoted vars without double quoting quoted vars diff --git a/R/geocode_combine.R b/R/geocode_combine.R index 9ad7d457..7b953a4c 100644 --- a/R/geocode_combine.R +++ b/R/geocode_combine.R @@ -168,7 +168,7 @@ geo_combine <- function(queries, global_params = list(), address = NULL, #' @export geocode_combine <- function(.tbl, queries, global_params = list(), return_list = FALSE, cascade = TRUE, query_names = NULL, - lat = lat, long = long) { + lat = 'lat', long = 'long') { # NSE - converts lat and long parameters to character values lat <- rm_quote(deparse(substitute(lat))) diff --git a/R/reverse_geo.R b/R/reverse_geo.R index 063cbc81..33f5912f 100644 --- a/R/reverse_geo.R +++ b/R/reverse_geo.R @@ -98,7 +98,7 @@ get_coord_parameters <- function(custom_query, method, lat, long) { #' } #' @seealso [reverse_geocode] [api_parameter_reference] [min_time_reference] [batch_limit_reference] #' @export -reverse_geo <- function(lat, long, method = 'osm', address = address, limit = 1, +reverse_geo <- function(lat, long, method = 'osm', address = 'address', limit = 1, full_results = FALSE, mode = '', unique_only = FALSE, return_coords = TRUE, min_time = NULL, progress_bar = show_progress_bar(), quiet = getOption("tidygeocoder.quiet", FALSE), api_url = NULL, timeout = 20, flatten = TRUE, diff --git a/R/reverse_geocode.R b/R/reverse_geocode.R index f6386b3b..5f0133ca 100644 --- a/R/reverse_geocode.R +++ b/R/reverse_geocode.R @@ -48,7 +48,7 @@ #' } #' @seealso [reverse_geo] #' @export -reverse_geocode <- function(.tbl, lat, long, address = address, return_input = TRUE, limit = 1, return_coords = NULL, unique_only = FALSE, ...) { +reverse_geocode <- function(.tbl, lat, long, address = 'address', return_input = TRUE, limit = 1, return_coords = NULL, unique_only = FALSE, ...) { # Non-standard evaluation -------------------------------------------------------------- # Quote unquoted vars without double quoting quoted vars diff --git a/man/geo.Rd b/man/geo.Rd index 2f92675e..3a850b11 100644 --- a/man/geo.Rd +++ b/man/geo.Rd @@ -14,8 +14,8 @@ geo( country = NULL, method = "osm", cascade_order = c("census", "osm"), - lat = lat, - long = long, + lat = "lat", + long = "long", limit = 1, full_results = FALSE, mode = "", diff --git a/man/geocode.Rd b/man/geocode.Rd index 0153ac2e..69b68fe7 100644 --- a/man/geocode.Rd +++ b/man/geocode.Rd @@ -13,8 +13,8 @@ geocode( state = NULL, postalcode = NULL, country = NULL, - lat = lat, - long = long, + lat = "lat", + long = "long", return_input = TRUE, limit = 1, return_addresses = NULL, diff --git a/man/geocode_combine.Rd b/man/geocode_combine.Rd index 47de54e7..40d74355 100644 --- a/man/geocode_combine.Rd +++ b/man/geocode_combine.Rd @@ -11,8 +11,8 @@ geocode_combine( return_list = FALSE, cascade = TRUE, query_names = NULL, - lat = lat, - long = long + lat = "lat", + long = "long" ) } \arguments{ diff --git a/man/reverse_geo.Rd b/man/reverse_geo.Rd index 4b1c95fc..bf79d8ed 100644 --- a/man/reverse_geo.Rd +++ b/man/reverse_geo.Rd @@ -8,7 +8,7 @@ reverse_geo( lat, long, method = "osm", - address = address, + address = "address", limit = 1, full_results = FALSE, mode = "", diff --git a/man/reverse_geocode.Rd b/man/reverse_geocode.Rd index 174edb0f..f48b13e1 100644 --- a/man/reverse_geocode.Rd +++ b/man/reverse_geocode.Rd @@ -8,7 +8,7 @@ reverse_geocode( .tbl, lat, long, - address = address, + address = "address", return_input = TRUE, limit = 1, return_coords = NULL, From 186655fda2fac1dda3da49372356e675bba80a9b Mon Sep 17 00:00:00 2001 From: Daniel Possenriede Date: Thu, 28 Oct 2021 17:36:43 +0200 Subject: [PATCH 2/2] style: one line per argument --- R/geo.R | 51 ++++++++++++++++++++++++++++++++++----------- R/geocode.R | 21 ++++++++++++++++--- R/geocode_combine.R | 14 ++++++++++--- R/reverse_geo.R | 37 +++++++++++++++++++++++++------- R/reverse_geocode.R | 15 +++++++++++-- 5 files changed, 110 insertions(+), 28 deletions(-) diff --git a/R/geo.R b/R/geo.R index 841ebe55..d4c2a568 100644 --- a/R/geo.R +++ b/R/geo.R @@ -145,18 +145,45 @@ progress_geo <- function(pb = NULL, ...) { #' } #' @seealso [geocode] [api_parameter_reference] [min_time_reference] [batch_limit_reference] #' @export -geo <- function(address = NULL, - street = NULL, city = NULL, county = NULL, state = NULL, postalcode = NULL, country = NULL, - method = 'osm', cascade_order = c('census', 'osm'), lat = 'lat', long = 'long', limit = 1, - full_results = FALSE, mode = '', unique_only = FALSE, return_addresses = TRUE, - min_time = NULL, progress_bar = show_progress_bar(), quiet = getOption("tidygeocoder.quiet", FALSE), - api_url = NULL, timeout = 20, flatten = TRUE, batch_limit = NULL, batch_limit_error = TRUE, - verbose = getOption("tidygeocoder.verbose", FALSE), no_query = FALSE, - custom_query = list(), api_options = list(), - return_type = 'locations', iq_region = 'us', geocodio_v = 1.6, - param_error = TRUE, mapbox_permanent = FALSE, here_request_id = NULL, - mapquest_open = FALSE) { - +geo <- + function( + address = NULL, + street = NULL, + city = NULL, + county = NULL, + state = NULL, + postalcode = NULL, + country = NULL, + method = 'osm', + cascade_order = c('census', 'osm'), + lat = 'lat', + long = 'long', + limit = 1, + full_results = FALSE, + mode = '', + unique_only = FALSE, + return_addresses = TRUE, + min_time = NULL, + progress_bar = show_progress_bar(), + quiet = getOption("tidygeocoder.quiet", FALSE), + api_url = NULL, + timeout = 20, + flatten = TRUE, + batch_limit = NULL, + batch_limit_error = TRUE, + verbose = getOption("tidygeocoder.verbose", FALSE), + no_query = FALSE, + custom_query = list(), + api_options = list(), + return_type = 'locations', + iq_region = 'us', + geocodio_v = 1.6, + param_error = TRUE, + mapbox_permanent = FALSE, + here_request_id = NULL, + mapquest_open = FALSE + ) { + # NSE - Quote unquoted vars without double quoting quoted vars # end result - all of these variables become character values lat <- rm_quote(deparse(substitute(lat))) diff --git a/R/geocode.R b/R/geocode.R index a480bd55..4d7a1622 100644 --- a/R/geocode.R +++ b/R/geocode.R @@ -57,9 +57,24 @@ #' } #' @seealso [geo] #' @export -geocode <- function(.tbl, address = NULL, street = NULL, city = NULL, county = NULL, - state = NULL, postalcode = NULL, country = NULL, - lat = 'lat', long = 'long', return_input = TRUE, limit = 1, return_addresses = NULL, unique_only = FALSE, ...) { +geocode <- + function( + .tbl, + address = NULL, + street = NULL, + city = NULL, + county = NULL, + state = NULL, + postalcode = NULL, + country = NULL, + lat = 'lat', + long = 'long', + return_input = TRUE, + limit = 1, + return_addresses = NULL, + unique_only = FALSE, + ... + ) { # Non-standard evaluation -------------------------------------------------------------- # Quote unquoted vars without double quoting quoted vars diff --git a/R/geocode_combine.R b/R/geocode_combine.R index 7b953a4c..7294db50 100644 --- a/R/geocode_combine.R +++ b/R/geocode_combine.R @@ -166,9 +166,17 @@ geo_combine <- function(queries, global_params = list(), address = NULL, #' } #' @seealso [geo_combine] [geo] [geocode] #' @export -geocode_combine <- function(.tbl, queries, global_params = list(), - return_list = FALSE, cascade = TRUE, query_names = NULL, - lat = 'lat', long = 'long') { +geocode_combine <- + function( + .tbl, + queries, + global_params = list(), + return_list = FALSE, + cascade = TRUE, + query_names = NULL, + lat = 'lat', + long = 'long' + ) { # NSE - converts lat and long parameters to character values lat <- rm_quote(deparse(substitute(lat))) diff --git a/R/reverse_geo.R b/R/reverse_geo.R index 33f5912f..f4452560 100644 --- a/R/reverse_geo.R +++ b/R/reverse_geo.R @@ -98,14 +98,35 @@ get_coord_parameters <- function(custom_query, method, lat, long) { #' } #' @seealso [reverse_geocode] [api_parameter_reference] [min_time_reference] [batch_limit_reference] #' @export -reverse_geo <- function(lat, long, method = 'osm', address = 'address', limit = 1, - full_results = FALSE, mode = '', unique_only = FALSE, return_coords = TRUE, - min_time = NULL, progress_bar = show_progress_bar(), quiet = getOption("tidygeocoder.quiet", FALSE), - api_url = NULL, timeout = 20, flatten = TRUE, - batch_limit = NULL, verbose = getOption("tidygeocoder.verbose", FALSE), - no_query = FALSE, custom_query = list(), api_options = list(), iq_region = 'us', geocodio_v = 1.6, - mapbox_permanent = FALSE, here_request_id = NULL, mapquest_open = FALSE) { - +reverse_geo <- + function( + lat, + long, + method = 'osm', + address = 'address', + limit = 1, + full_results = FALSE, + mode = '', + unique_only = FALSE, + return_coords = TRUE, + min_time = NULL, + progress_bar = show_progress_bar(), + quiet = getOption("tidygeocoder.quiet", FALSE), + api_url = NULL, + timeout = 20, + flatten = TRUE, + batch_limit = NULL, + verbose = getOption("tidygeocoder.verbose", FALSE), + no_query = FALSE, + custom_query = list(), + api_options = list(), + iq_region = 'us', + geocodio_v = 1.6, + mapbox_permanent = FALSE, + here_request_id = NULL, + mapquest_open = FALSE + ) { + # NSE eval address <- rm_quote(deparse(substitute(address))) diff --git a/R/reverse_geocode.R b/R/reverse_geocode.R index 5f0133ca..217cf651 100644 --- a/R/reverse_geocode.R +++ b/R/reverse_geocode.R @@ -48,8 +48,19 @@ #' } #' @seealso [reverse_geo] #' @export -reverse_geocode <- function(.tbl, lat, long, address = 'address', return_input = TRUE, limit = 1, return_coords = NULL, unique_only = FALSE, ...) { - +reverse_geocode <- + function( + .tbl, + lat, + long, + address = 'address', + return_input = TRUE, + limit = 1, + return_coords = NULL, + unique_only = FALSE, + ... + ) { + # Non-standard evaluation -------------------------------------------------------------- # Quote unquoted vars without double quoting quoted vars # end result - all of these variables become character values