From ad5e49d70c9784e7a8e4e3ff8c2c040ab1ec2b69 Mon Sep 17 00:00:00 2001 From: Flavio Poletti Date: Fri, 20 Dec 2024 08:18:40 +0100 Subject: [PATCH] bugfix filter_stop_times: catch NAs for missing max_arrival_time --- R/travel_times.R | 2 +- tests/testthat/test-travel_times.R | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/R/travel_times.R b/R/travel_times.R index 9cee757..774d242 100644 --- a/R/travel_times.R +++ b/R/travel_times.R @@ -214,7 +214,7 @@ filter_stop_times = function(gtfs_obj, min_departure_time <- hhmmss_to_seconds(min_departure_time) } if(missing(max_arrival_time)) { - max_arrival_time <- max(gtfs_obj$stop_times$arrival_time)+1 + max_arrival_time <- max(gtfs_obj$stop_times$arrival_time, na.rm = TRUE)+1 } else if(is.character(max_arrival_time)) { max_arrival_time <- hhmmss_to_seconds(max_arrival_time) } diff --git a/tests/testthat/test-travel_times.R b/tests/testthat/test-travel_times.R index 1852ed2..4c96401 100644 --- a/tests/testthat/test-travel_times.R +++ b/tests/testthat/test-travel_times.R @@ -120,6 +120,7 @@ test_that("travel_times with filtered feed", { }) test_that("time_range param", { + expect_is(filter_feed_by_date(gtfs_duke, "2019-10-01"), "tidygtfs") st = filter_feed_by_date(gtfs_routing, "2018-10-01") tt1 = travel_times(st, stop_name = "One", time_range = c("07:09:00", "07:59:00"))