Use local environmental variables specifying home and work stations and locations of locally-stored GTFS data to route from home to work location with next available service.
go_to_work(wait = 0, start_time)
An integer specifying the n-th next service. That is, wait = n
will return the n-th available service after the next immediate service.
If given, search for connections after specified time; if not given, search for connections from current time.
A data.frame
specifying the next available route from work to home.
This function, and the complementary function go_to_work,
requires three local environmental variables specifying the names of home and
work stations, and the location on local storage of the GTFS data set to be
used for routing. These are respectively called gtfs_home
, gtfs_work
, and
gtfs_data
. This data set must also be pre-processed using the
process_gtfs_local function.
See Startup for details on how to set environmental variables.
Briefly, this can be done in two main ways: By setting them at the start of
each session, in which case the variables may be set with:
Sys.setenv ("gtfs_home" = "<my home station>")
Sys.setenv ("gtfs_work" = "<my work station>")
Sys.setenv ("gtfs_data" = "/full/path/to/gtfs.zip")
Alternatively, to set these automatically for each session, paste those lines
into the file ~/.Renviron
- that is, a file named ".Renviron" in the user's
home directory.
The process_gtfs_local function reduces the GTFS data set to the minimal possible size necessary for local routing. GTFS data are nevertheless typically quite large, and both the go_home and go_to_work functions may take some time to execute. Most of this time is devoted to loading the data in to the current workspace and as such is largely unavoidable.
Other additional:
go_home()
,
plot.gtfs_ischrone
,
process_gtfs_local()
,
summary.gtfs()
if (FALSE) {
# For general use, please set these three variables:
Sys.setenv ("gtfs_home" = "<my home station>")
Sys.setenv ("gtfs_work" = "<my work station>")
Sys.setenv ("gtfs_data" = "/full/path/to/gtfs.zip")
}
# The following illustrate use with sample data bundled with package
Sys.setenv ("gtfs_home" = "Tempelhof")
Sys.setenv ("gtfs_work" = "Alexanderplatz")
Sys.setenv ("gtfs_data" = file.path (tempdir (), "vbb.zip"))
process_gtfs_local () # If not already done
go_to_work (start_time = "12:00") # next available service after 12:00
#> route_name trip_name stop_name
#> 1 U6 U Alt-Tegel S+U Tempelhof (Berlin)
#> 2 U6 U Alt-Tegel U Paradestr. (Berlin)
#> 3 U6 U Alt-Tegel U Platz der Luftbrucke (Berlin)
#> 4 U6 U Alt-Tegel U Mehringdamm (Berlin)
#> 5 U6 U Alt-Tegel U Hallesches Tor (Berlin)
#> 6 U6 U Alt-Tegel U Kochstr./Checkpoint Charlie (Berlin)
#> 7 U6 U Alt-Tegel U Stadtmitte (Berlin)
#> 8 U6 U Alt-Tegel U Franzosische Str. (Berlin)
#> 9 U6 U Alt-Tegel S+U Friedrichstr. Bhf (Berlin)
#> 10 S7 S Ahrensfelde Bhf S+U Friedrichstr. Bhf (Berlin)
#> 11 S7 S Ahrensfelde Bhf S Hackescher Markt (Berlin)
#> 12 S7 S Ahrensfelde Bhf S+U Alexanderplatz Bhf (Berlin)
#> arrival_time departure_time
#> 1 12:02:30 12:02:30
#> 2 12:04:00 12:04:00
#> 3 12:05:30 12:05:30
#> 4 12:07:30 12:07:30
#> 5 12:09:00 12:09:00
#> 6 12:10:30 12:10:30
#> 7 12:12:00 12:12:00
#> 8 12:13:00 12:13:00
#> 9 12:14:30 12:14:30
#> 10 12:20:36 12:21:24
#> 11 12:22:54 12:23:24
#> 12 12:24:36 12:25:24
go_to_work (3, start_time = "12:00") # Wait until third service after that
#> route_name trip_name stop_name
#> 1 U6 U Alt-Tegel S+U Tempelhof (Berlin)
#> 2 U6 U Alt-Tegel U Paradestr. (Berlin)
#> 3 U6 U Alt-Tegel U Platz der Luftbrucke (Berlin)
#> 4 U6 U Alt-Tegel U Mehringdamm (Berlin)
#> 5 U6 U Alt-Tegel U Hallesches Tor (Berlin)
#> 6 U6 U Alt-Tegel U Kochstr./Checkpoint Charlie (Berlin)
#> 7 U6 U Alt-Tegel U Stadtmitte (Berlin)
#> 8 U6 U Alt-Tegel U Franzosische Str. (Berlin)
#> 9 U6 U Alt-Tegel S+U Friedrichstr. Bhf (Berlin)
#> 10 S7 S Ahrensfelde Bhf S+U Friedrichstr. Bhf (Berlin)
#> 11 S7 S Ahrensfelde Bhf S Hackescher Markt (Berlin)
#> 12 S7 S Ahrensfelde Bhf S+U Alexanderplatz Bhf (Berlin)
#> arrival_time departure_time
#> 1 12:12:30 12:12:30
#> 2 12:14:00 12:14:00
#> 3 12:15:30 12:15:30
#> 4 12:17:30 12:17:30
#> 5 12:19:00 12:19:00
#> 6 12:20:30 12:20:30
#> 7 12:22:00 12:22:00
#> 8 12:23:00 12:23:00
#> 9 12:24:30 12:24:30
#> 10 12:30:36 12:31:24
#> 11 12:32:54 12:33:24
#> 12 12:34:36 12:35:24
# Generally, `start_time` will not be specified, in which case `go_to_work`
# will return next available service from current system time, so calls will
# generally be as simple as:
if (FALSE) {
go_to_work ()
go_to_work (3)
}