r-transit / gtfsio

Read and Write General Transit Feed Specification (GTFS)
https://r-transit.github.io/gtfsio/
Other
13 stars 3 forks source link

`check_field_class()` raises error when any of the columns of the specified table has more than one class #31

Open dhersz opened 1 year ago

dhersz commented 1 year ago

This is using the dev version

library(tidytransit)

local_gtfs_path <- system.file("extdata", "google_transit_nyc_subway.zip", package = "tidytransit")
gtfs <- read_gtfs(local_gtfs_path)

gtfsio::check_field_class(gtfs, "stop_times", "arrival_time", "hms")
#> Error in vapply(x[[file]], class, character(1)): values must be length 1,
#>  but FUN(X[[2]]) result is length 2

class(gtfs$stop_times$arrival_time)
#> [1] "hms"      "difftime"

class(gtfs$stop_times$arrival_time) <- "hms"
class(gtfs$stop_times$departure_time) <- "hms"
gtfsio::check_field_class(gtfs, "stop_times", "arrival_time", "hms")
#> [1] TRUE