Use local environmental variables specifying home and work stations and locations of locally-stored GTFS data to route from work to home location with next available service.
go_home(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_to_work()
,
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_home (start_time = "12:00") # next available service after 12:00
#> route_name trip_name stop_name
#> 1 S3 S Spandau Bhf S+U Alexanderplatz Bhf (Berlin)
#> 2 S3 S Spandau Bhf S Hackescher Markt (Berlin)
#> 3 S3 S Spandau Bhf S+U Friedrichstr. Bhf (Berlin)
#> 4 U6 U Alt-Mariendorf S+U Friedrichstr. Bhf (Berlin)
#> 5 U6 U Alt-Mariendorf U Franzosische Str. (Berlin)
#> 6 U6 U Alt-Mariendorf U Stadtmitte (Berlin)
#> 7 U6 U Alt-Mariendorf U Kochstr./Checkpoint Charlie (Berlin)
#> 8 U6 U Alt-Mariendorf U Hallesches Tor (Berlin)
#> 9 U6 U Alt-Mariendorf U Mehringdamm (Berlin)
#> 10 U6 U Alt-Mariendorf U Platz der Luftbrucke (Berlin)
#> 11 U6 U Alt-Mariendorf U Paradestr. (Berlin)
#> 12 U6 U Alt-Mariendorf S+U Tempelhof (Berlin)
#> arrival_time departure_time
#> 1 12:02:54 12:03:42
#> 2 12:04:54 12:05:24
#> 3 12:06:54 12:07:42
#> 4 12:14:00 12:14:00
#> 5 12:15:00 12:15:00
#> 6 12:16:30 12:16:30
#> 7 12:17:30 12:17:30
#> 8 12:19:00 12:19:00
#> 9 12:20:30 12:21:00
#> 10 12:23:00 12:23:00
#> 11 12:24:30 12:24:30
#> 12 12:26:00 12:26:00
go_home (3, start_time = "12:00") # Wait until third service after that
#> route_name trip_name stop_name
#> 1 U8 S+U Hermannstr. S+U Alexanderplatz (Berlin) [U8]
#> 2 U8 S+U Hermannstr. S+U Jannowitzbrucke (Berlin)
#> 3 U8 S+U Hermannstr. U Heinrich-Heine-Str. (Berlin)
#> 4 U8 S+U Hermannstr. U Moritzplatz (Berlin)
#> 5 U8 S+U Hermannstr. U Kottbusser Tor (Berlin)
#> 6 U8 S+U Hermannstr. U Schonleinstr. (Berlin)
#> 7 U8 S+U Hermannstr. U Hermannplatz (Berlin)
#> 8 U8 S+U Hermannstr. U Boddinstr. (Berlin)
#> 9 U8 S+U Hermannstr. U Leinestr. (Berlin)
#> 10 U8 S+U Hermannstr. S+U Hermannstr. (Berlin)
#> 11 S46 S+U Gesundbrunnen Bhf S+U Hermannstr. (Berlin)
#> 12 S46 S+U Gesundbrunnen Bhf S+U Tempelhof (Berlin)
#> arrival_time departure_time
#> 1 12:18:30 12:18:30
#> 2 12:20:00 12:20:00
#> 3 12:21:30 12:21:30
#> 4 12:23:00 12:23:00
#> 5 12:25:00 12:25:00
#> 6 12:26:30 12:26:30
#> 7 12:28:30 12:28:30
#> 8 12:30:00 12:30:00
#> 9 12:31:30 12:31:30
#> 10 12:32:30 12:32:30
#> 11 12:34:54 12:35:24
#> 12 12:38:42 12:39:12
# Generally, `start_time` will not be specified, in which case `go_home` will
# return next available service from current system time, so calls will
# generally be as simple as:
if (FALSE) {
go_home ()
go_home (3)
}