Filters a GTFS object by service_id
s, keeping (or dropping) the relevant
entries in each file.
filter_by_service_id(gtfs, service_id, keep = TRUE)
A GTFS object, as created by read_gtfs()
.
A character vector. The service_id
s used to filter the
data.
A logical. Whether the entries related to the specified
service_id
s should be kept or dropped (defaults to TRUE
, which keeps the
entries).
The GTFS object passed to the gtfs
parameter, after the filtering
process.
Other filtering functions:
filter_by_agency_id()
,
filter_by_route_id()
,
filter_by_route_type()
,
filter_by_sf()
,
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/spo_gtfs.zip", package = "gtfstools")
gtfs <- read_gtfs(data_path)
service_ids <- c("USD", "U__")
object.size(gtfs)
#> 811304 bytes
# keeps entries related to the specified service_ids
smaller_gtfs <- filter_by_service_id(gtfs, service_ids)
object.size(smaller_gtfs)
#> 810568 bytes
# drops entries related to the specified service_ids
smaller_gtfs <- filter_by_service_id(gtfs, service_ids, keep = FALSE)
object.size(smaller_gtfs)
#> 19648 bytes