Skip to content

R package to generate departure times for accessibility analysis

License

Notifications You must be signed in to change notification settings

stmarcin/DepartureTime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Status: Active Travis build status

DepartureTime

R package to generate departure times for accessibility analysis

Description

The goal of DepartureTime is to prepare a data.frame which contains generated departure times, using user-defined:

  • sampling method
  • date
  • time-window
  • path and file name

Supported sampling methods:

  • Systematic sampling method: departure times are selected using a regular interval defined by the frequency
  • Simple Random sampling method: a specified number of departure times (defined by the frequency) is randomly selected from the time window
  • Hybrid sampling method: departure times are randomly selected from given time intervals (resulted from applied temporal resolution)
  • Constrained Random Walk Sampling sampling method: a first departure time is randomly selected from the subset of the length defined by the frequency and beginning of the time window; then, the next departure time is randomly selected from the subset limited by (Tn+f/2) and (Tn+f+f/2)

Example (temporal resolution 20 minutes, time window 07:00 - 08:00):

Sampling method Departure times Comments
Systematic 07:00; 07:20, 7:40, 08:00 regular interval of 20 minutes1
Simple Random 07:18; 07:51; 07:55 3 randomly selected departure times from the time window2
Hybrid 07:02; 07:23; 07:50 One randomly selected departure time from each time interval period3
Random Walk 07:15; 07:36; 07:49 on average there should be 20-minute interval between departure times4

1 as 20-minute interval fits to 60 minute time window it provides 4 departure times.
2 i.e. one per each 20 min. in 60-minute time window.
3 i.e. one from 07:00-07:19, one from 07:20-07:39 and one from 07:40-07:59.
4 due to the nature of the sampling procedure, the number of departure times might differ.

For details please consult Owen & Murphy (2018).

Installation

You can install DepartureTime pacakage from GitHub with:

# install.packages("devtools")
devtools::install_github("stmarcin/DepartureTime")

Function syntax:

DepartureTime <- function(method = "H",
                          dy = format(Sys.Date(), "%Y"),  
                          dm = format(Sys.Date(), "%m"), 
                          dd = format(Sys.Date(), "%d"),
                          tmin = 0, tmax = 24,
                          res = 5,
                          MMDD = TRUE,
                          ptw = FALSE)

Function variables:

  • method - sampling method; Options:
    • R OR Random: Simple random sampling;
    • S OR Systematic: Systematic sampling;
    • H OR Hybrid: Hybrid sampling;
    • W OR Walk: Constrained random walk sampling;
  • dy, dm and dd - date of the analysis (formats: YYYY, MM, DD); default: system date;
  • tmin and tmax - limits of the time window (format: HH); default: full day (00:00 - 24:00);
  • res - temporal resolution; default: 5 minutes
  • MMDD - date format of the output (TRUE / FALSE) default: TRUE
    • TRUE: MM/DD/YYYY;
    • FALSE: DD/MM/YYYY;
  • ptw - print limits of subsetted time-windows; default: FALSE;

Output

data.frame which contains generated departure times (to be used e.g. in ArcGIS Network to generated ODs with time-dependent transport data, e.g. GTFS). File structure:

ColumnName

Description

ID

rowID (integer), starts with 0

Date

Departure date & hour

Examples

Working example, uses all default variables and hybrid sampling method:

library(DepartureTime)

DepartureTime() %>% 
  head()

ID

Date

0

05/16/2020 00:01

1

05/16/2020 00:06

2

05/16/2020 00:12

3

05/16/2020 00:18

4

05/16/2020 00:22

5

05/16/2020 00:27

Example with user-defined parameters:

DepartureTime(method = "S",    # systematic sampling method
  dm = 5, dd = 15,             # user-defined date: 15th May, 2020 (current year)
  tmin = 7, tmax = 9,          # user-defined time window (07:00 - 09:00)
  res = 20)                    # user-defined temporal resolution (20 minutes)

ID

Date

0

05/15/2020 07:00

1

05/15/2020 07:20

2

05/15/2020 07:40

3

05/15/2020 08:00

4

05/15/2020 08:20

5

05/15/2020 08:40

6

05/15/2020 09:00

Direct export to .dbf

If you don’t want/need to revise departure times, you can easily export them directly, e.g. to .dbf file using {foreign} package:

library(DepartureTime)
library(foreign)
library(dplyr)

# generate departure times for 8-10am time window 
# with 30-minute temporal resolution applying hybrid sampling model:
DepartureTime(tmin = 8, tmax = 10, res = 30) %>% 
  
  #save output in OD_analysis subfolder as My_Departure_Times.dbf
  write.dbf("OD_analysis/My_Departure_Times.dbf")
  

Background

This script was inspired by Owen & Murphy (2018) study and was developed when working on Stępniak et al. (2019) paper:

Stępniak, M., Pritchard, J.P., Geurs K.T., Goliszek S., 2019, The impact of temporal resolution on public transport accessibility measurement: review and case study in Poland, Journal of Transport Geography.

Funding statement

This document was created within the MSCA CAlCULUS project.

This project has received funding from the European Union’s Horizon 2020 research and innovation Programme under the Marie Sklodowska-Curie Grant Agreement no. 749761.
The views and opinions expressed herein do not necessarily reflect those of the European Commission.

About

R package to generate departure times for accessibility analysis

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages