View source: R/convert_time_to_seconds.R
convert_time_to_seconds | R Documentation |
Converts stop_times
' and frequencies
' fields in the "HH:MM:SS" format to
seconds after midnight. Instead of overwritting the existing fields, creates
new fields with the _secs
suffix.
convert_time_to_seconds(gtfs, file = NULL, by_reference = FALSE)
gtfs |
A GTFS object, as created by |
file |
A character vector, specifying the file whose fields should be
converted. If |
by_reference |
Whether to update the tables by reference. Defaults to
|
If by_reference
is FALSE
, returns a GTFS object with additional
time in seconds columns (identified by a _secs
suffix). Else, returns a
GTFS object invisibly (please note that in such case the original GTFS object
is altered).
data_path <- system.file("extdata/spo_gtfs.zip", package = "gtfstools")
gtfs <- read_gtfs(data_path)
# by default converts both 'stop_times' and 'frequencies' times
converted_gtfs <- convert_time_to_seconds(gtfs)
head(converted_gtfs$stop_times)
head(converted_gtfs$frequencies)
# choose which table to convert with 'file'
converted_gtfs <- convert_time_to_seconds(gtfs, file = "frequencies")
head(converted_gtfs$stop_times)
head(converted_gtfs$frequencies)
# original gtfs remained unchanged, as seen with the frequencies table above
# change original object without creating a copy with 'by_reference = TRUE'
convert_time_to_seconds(gtfs, by_reference = TRUE)
head(gtfs$stop_times)
head(gtfs$frequencies)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.