remove_unused_ids: Remove unused ids

View source: R/remove_unused_ids.R

remove_unused_idsR Documentation

Remove unused ids

Description

Removes the ids that the feed doesn't use, with their entries in every file. A trip is used if it has stop_times, and anything that a used trip refers to, directly or indirectly, is used too. Entries that refer to removed ids are removed as well, including those in attributions and translations. When there are no fare_rules, fare_attributes and their agencies are kept, since these fares apply to the whole feed. Fares v2 and GTFS-Flex files are left unchanged, so they may still refer to removed ids.

Usage

remove_unused_ids(gtfs)

Arguments

gtfs

A GTFS object, as created by read_gtfs().

Value

The GTFS object without unused ids.

See Also

filter_by_trip_id(), remove_duplicates()

Examples


data_path <- system.file("extdata/ber_gtfs.zip", package = "gtfstools")
gtfs <- read_gtfs(data_path)
nrow(gtfs$agency)

gtfs <- remove_unused_ids(gtfs)
nrow(gtfs$agency)


gtfstools documentation built on Oct. 28, 2026, 5:13 p.m.