This vignette covers how to use function myfavrt to set up a favorite route get real-time information in the rCTA package. It allows users to get a dataframe of estimated arrival time, waiting time, travel time, delay and alert message. It also allows users to collect and save the real-time information for a given period in a data frame through calling the function periodically.

NOTE: Since the CTA system updates data about once per minute, it may generate error message No arrival times if the system has not been updated yet. Also, it may generate an error message No service scheduled when you request at a time out of operation.

Get Real-time Traveling Information

Function myfavrt() allows to set up your favorite routes based on bus, start_id and end_id:

  • bus: bus number.
  • start_id: ID of the departure stop. This can be look up through function lookupstop in this package.
  • end_id: ID of the destination stop. This can be look up through function lookupstop in this package.

After setting up, this function will provide you a set of real-time information and about your traveling, including:

  • wait time (in min)
  • travel time (in min)
  • arrival time
  • delay information
  • alert information

For example:

Get the information of my favorite route as a dataframe. In this example, we only collect the real-time information once, so we set the arguments interval to 0, and times to 1.

result <- myfavrt(bus = 126, start_id = 36, end_id = 60, interval= 0, times = 1)
knitr::kable(head(result))
no. current_time bus_num start_stop_id start_stop_name end_stop_id end_stop_name wait_time_in_min departurel_time arrival_time travel_time_in_min delay status
126 20181217 12:32 126 36 Jackson + 2609 West Alley 60 Jackson + Aberdeen 14 20181217 12:47 20181217 12:58 11 mins FALSE Planned Reroute

Collect and Save the Real-time Information Periodically

This function also allow users to collect and save the real-time information in a dataframe through calling the function periodically.

For example:

Get my favorite route as above, collect the real-time information once per minute, and repeat 5 times.

result <- myfavrt(bus = 126, start_id = 36, end_id = 60, interval= 60, times = 5)
knitr::kable(head(result))
no. current_time bus_num start_stop_id start_stop_name end_stop_id end_stop_name wait_time_in_min departurel_time arrival_time travel_time_in_min delay status
126 20181217 12:32 126 36 Jackson + 2609 West Alley 60 Jackson + Aberdeen 14 20181217 12:47 20181217 12:58 11 mins FALSE Planned Reroute
126 20181217 12:33 126 36 Jackson + 2609 West Alley 60 Jackson + Aberdeen 13 20181217 12:47 20181217 12:58 11 mins FALSE Planned Reroute
126 20181217 12:34 126 36 Jackson + 2609 West Alley 60 Jackson + Aberdeen 12 20181217 12:46 20181217 12:57 11 mins FALSE Planned Reroute
126 20181217 12:35 126 36 Jackson + 2609 West Alley 60 Jackson + Aberdeen 12 20181217 12:47 20181217 12:58 11 mins FALSE Planned Reroute
126 20181217 12:36 126 36 Jackson + 2609 West Alley 60 Jackson + Aberdeen 11 20181217 12:47 20181217 12:58 11 mins FALSE Planned Reroute