`get_parent_station()` creating `<NA>` stop_ids
dhersz opened this issue · 2 comments
dhersz commented
library(gtfstools)
ber_path <- system.file("extdata/ber_gtfs.zip", package = "gtfstools")
ber_gtfs <- read_gtfs(ber_path)
ber_shapes <- c("14", "2")
smaller_ber <- filter_shape_id(ber_gtfs, ber_shapes)
get_parent_station(ber_gtfs, smaller_ber$stop_times$stop_id)
#> stop_id parent_station
#> 1: 100000471802 900000200000
#> 2: 100000471901 900000203376
#> 3: 100000471002 900000203365
#> 4: 100000471602 900000200102
#> 5: 100000471201 900000203369
#> ---
#> 143: 900000210216 <NA>
#> 144: 900000210217 <NA>
#> 145: 900000210325 <NA>
#> 146: 900000210005 <NA>
#> 147: <NA> <NA>
Created on 2021-10-28 by the reprex package (v2.0.1.9000)
The NAs in the parent_station column are expected, the one in the stop_id is not.
dhersz commented
Actually, the NAs in the parent_station column are NOT expected either. This is because the parent_stations listed in the stops table are not listed themselves as stop_ids in the table.
dhersz commented
Fixed in d353fab:
library(gtfstools)
ber_path <- system.file("extdata/ber_gtfs.zip", package = "gtfstools")
ber_gtfs <- read_gtfs(ber_path)
ber_shapes <- c("14", "2")
smaller_ber <- filter_shape_id(ber_gtfs, ber_shapes)
get_parent_station(ber_gtfs, smaller_ber$stop_times$stop_id)
#> stop_id parent_station
#> 1: 100000471802 900000200000
#> 2: 100000471901 900000203376
#> 3: 100000471002 900000203365
#> 4: 100000471602 900000200102
#> 5: 100000471201 900000203369
#> ---
#> 142: 900000210272
#> 143: 900000210216
#> 144: 900000210217
#> 145: 900000210325
#> 146: 900000210005
Created on 2021-10-28 by the reprex package (v2.0.1.9000)