| as_dt_gtfs | R Documentation |
Coerces an existing object, such as a list or a GTFS object created from
other packages ({tidytransit} and {gtfsio}, for example) into a
gtfstools-compatible GTFS object - i.e. one whose internal tables are
represented with data.tables and whose fields are formatted like the fields
of a feed read with read_gtfs().
as_dt_gtfs() is an S3 generic, with methods for:
tidygtfs: the class of GTFS objects read with tidytransit::read_gtfs().
This method converts all tibbles to data.tables and convert time columns,
represented as hms objects in a tidygtfs, to strings in the "HH:MM:SS"
format.
gtfs: the class of GTFS objects read with gtfsio::import_gtfs(). This
method convert all date fields, represented as integers in {gtfsio}'s
representation, to Date objects.
list: this method tries to convert the elements of a list into
data.tables. Please note that all list elements must inherit from
data.frame and must be named. This method does not try not convert fields
to the representation used in {gtfstools}, as it does not have any
information on how they are formatted in the first place.
as_dt_gtfs(gtfs, ...)
## S3 method for class 'tidygtfs'
as_dt_gtfs(gtfs, calculate_distance = TRUE, ...)
## S3 method for class 'gtfs'
as_dt_gtfs(gtfs, ...)
## S3 method for class 'list'
as_dt_gtfs(gtfs, ...)
gtfs |
The object that should be coerced to a |
... |
Ignored. |
calculate_distance |
A logical. Passed to |
A dt_gtfs GTFS object.
data_path <- system.file("extdata/spo_gtfs.zip", package = "gtfstools")
gtfsio_gtfs <- gtfsio::import_gtfs(data_path)
class(gtfsio_gtfs)
gtfstools_gtfs <- as_dt_gtfs(gtfsio_gtfs)
class(gtfstools_gtfs)
gtfs_like_list <- unclass(gtfsio_gtfs)
class(gtfs_like_list)
gtfstools_gtfs <- as_dt_gtfs(gtfs_like_list)
class(gtfstools_gtfs)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.