Returns the (recursive) parent stations of each specified
Recursive in this context means it returns all parents' parents (i.e. first
parents, then parents' parents, and then their parents, and so on).
get_parent_station(gtfs, stop_id = NULL)
A GTFS object, as created by
A string vector including the
stop_ids to have their parents
NULL (the default), the function returns the parents of
stop_id in the GTFS.
data.table containing the
stop_ids and their
If a stop doesn't have a parent, its correspondent
is marked as
data_path <- system.file("extdata/ggl_gtfs.zip", package = "gtfstools") gtfs <- read_gtfs(data_path) parents <- get_parent_station(gtfs) head(parents) #> stop_id parent_station #> 1: F12 #> 2: E1 F12 #> 3: E2 F12 #> 4: E3 F12 #> 5: E4 F12 #> 6: E5 F12 # use the stop_id argument to control which stops are analyzed parents <- get_parent_station(gtfs, c("B1", "B2")) parents #> stop_id parent_station #> 1: B1 F12S #> 2: B2 F12N #> 3: F12S F12 #> 4: F12N F12 #> 5: F12