From ff3e5b47560c2aa6596705a289a202ee79f1332f Mon Sep 17 00:00:00 2001 From: DavisVaughan Date: Mon, 27 Feb 2023 14:58:31 -0500 Subject: [PATCH 1/3] Require dplyr >=1.1.0 for non-equi joins --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 7e0a6d19..62e59c2b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -26,7 +26,7 @@ LazyData: TRUE Depends: R (>= 3.6.0) Imports: gtfsio (>= 0.1.0), - dplyr, + dplyr (>= 1.1.0), data.table (>= 1.12.8), rlang, sf, From e215f9ca7822197da85f1a8b614adae206726bf9 Mon Sep 17 00:00:00 2001 From: DavisVaughan Date: Mon, 27 Feb 2023 14:59:01 -0500 Subject: [PATCH 2/3] Use a non-equi join in `set_dates_service()` --- R/dates.R | 8 ++++---- R/globals.R | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/R/dates.R b/R/dates.R index 6be379f1..75ec867d 100644 --- a/R/dates.R +++ b/R/dates.R @@ -93,11 +93,11 @@ set_dates_services <- function(gtfs_obj) { dplyr::filter(bool == 1) %>% dplyr::select(service_id, weekday, start_date, end_date) # set services to dates according to weekdays and start/end date - date_service_df <- - suppress_matches_multiple_warning( - dplyr::full_join(dates, service_ids_weekdays, by="weekday") + date_service_df <- dates %>% + dplyr::inner_join( + service_ids_weekdays, + by = dplyr::join_by(weekday, between(date, start_date, end_date)) ) %>% - dplyr::filter(date >= start_date & date <= end_date) %>% dplyr::select(-weekday, -start_date, -end_date) # addtions and exceptions diff --git a/R/globals.R b/R/globals.R index 737bc894..be5c6f39 100644 --- a/R/globals.R +++ b/R/globals.R @@ -50,7 +50,8 @@ if (getRversion() >= "3.1.0") { "start_time", "end_time", "feed_start_date", - "feed_end_date" + "feed_end_date", + "between" ) ) } \ No newline at end of file From 14b2dc8f8ebbf0ec4e40fe0460abe28e37acc476 Mon Sep 17 00:00:00 2001 From: DavisVaughan Date: Mon, 27 Feb 2023 14:59:49 -0500 Subject: [PATCH 3/3] Simplify `inner_join()` in `get_trip_geometry()` --- R/spatial.R | 11 ++++++++--- R/utils.R | 13 ------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/R/spatial.R b/R/spatial.R index 018b379c..f7f8a711 100644 --- a/R/spatial.R +++ b/R/spatial.R @@ -146,9 +146,14 @@ get_trip_geometry <- function(gtfs_sf_obj, trip_ids) { } trips = gtfs_sf_obj$trips %>% filter(trip_id %in% trip_ids) - trips_shapes = suppress_matches_multiple_warning( - dplyr::inner_join(gtfs_sf_obj$shapes, trips, by = "shape_id") - ) + + if (utils::packageVersion("dplyr") >= "1.1.0.9000") { + trips_shapes = dplyr::inner_join(gtfs_sf_obj$shapes, trips, by = "shape_id") + } else { + # TODO: Remove after dplyr 1.1.1 is released + trips_shapes = dplyr::inner_join(gtfs_sf_obj$shapes, trips, by = "shape_id", multiple = "all") + } + return(trips_shapes) } diff --git a/R/utils.R b/R/utils.R index e450bd9e..4eb1a975 100644 --- a/R/utils.R +++ b/R/utils.R @@ -48,16 +48,3 @@ na_to_empty_strings = function(gtfs_obj) { df }) } - -# TODO: Remove after dplyr 1.1.0 is released and use `multiple = "all"` instead -suppress_matches_multiple_warning <- function(expr) { - handler_matches_multiple <- function(cnd) { - if (inherits(cnd, "dplyr_warning_join_matches_multiple")) { - restart <- findRestart("muffleWarning") - if (!is.null(restart)) { - invokeRestart(restart) - } - } - } - withCallingHandlers(expr, warning = handler_matches_multiple) -}