View source: R/filter_by_date.R
| filter_by_date | R Documentation |
Filters a GTFS object by the services that run on the given dates, keeping (or dropping) the relevant entries in each file.
filter_by_date(gtfs, date, keep = TRUE)
gtfs |
A GTFS object, as created by |
date |
A |
keep |
A logical. Whether the entries related to the services that run
on the specified dates should be kept or dropped (defaults to |
The GTFS object passed to the gtfs parameter, after the filtering
process.
The services that run on at least one of the given dates are kept (or
dropped) as a whole: their calendar and calendar_dates entries are not
trimmed to the given dates, so they may still run on other dates.
A service runs on a date if its calendar entry spans the date and flags
its weekday, unless the date is removed from it in calendar_dates
(exception_type 2), or if the date is added to it in calendar_dates
(exception_type 1). An addition wins over a removal on the same date.
Either table may be missing. If both are missing, the GTFS object is
returned unchanged, with a warning.
filter_by_weekday(), get_calendar_overlap()
Other filtering functions:
filter_by_agency_id(),
filter_by_period(),
filter_by_route_id(),
filter_by_route_type(),
filter_by_service_id(),
filter_by_shape_id(),
filter_by_spatial_extent(),
filter_by_stop_id(),
filter_by_time_of_day(),
filter_by_trip_id(),
filter_by_weekday()
data_path <- system.file("extdata/ggl_gtfs.zip", package = "gtfstools")
gtfs <- read_gtfs(data_path)
# on 2006-07-03 (a monday) the weekday service "WD" is replaced by the
# weekend service "WE", according to the calendar_dates table
gtfs$calendar_dates
smaller_gtfs <- filter_by_date(gtfs, "2006-07-03")
smaller_gtfs$calendar
# dates may also be given as Date objects. drops the services that run on
# 2006-07-05 (a wednesday)
smaller_gtfs <- filter_by_date(gtfs, as.Date("2006-07-05"), keep = FALSE)
smaller_gtfs$calendar
# a vector of dates keeps the services that run on at least one of them
week <- seq(as.Date("2006-07-01"), as.Date("2006-07-07"), by = "day")
smaller_gtfs <- filter_by_date(gtfs, week)
smaller_gtfs$calendar
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.