merge_gtfs: Merge GTFS files

View source: R/merge_gtfs.R

merge_gtfsR Documentation

Merge GTFS files


Combines many GTFS objects into a single one.


merge_gtfs(..., files = NULL, warnings, prefix = FALSE)



GTFS objects to be merged. Each argument can either be a GTFS or a list of GTFS objects.


A character vector listing the GTFS tables to be merged. If NULL (the default), all tables are merged.


Whether to display warning messages (defaults to TRUE).


Either a logical or a character vector (defaults to FALSE). Whether to add a prefix to the value of id fields that identify from which GTFS object the value comes from. If TRUE, the prefixes will range from "1" to n, where n is the number of objects passed to the function. If a character vector, its elements will be used to identify the GTFS objects, and the length of the vector must equal the total amount of objects passed in ... (the first element will identify the first GTFS, the second element the second GTFS, and so on).


A GTFS object in which each table is a combination (by row) of the tables from the specified GTFS objects.


spo_path <- system.file("extdata/", package = "gtfstools")
ggl_path <- system.file("extdata/", package = "gtfstools")

spo_gtfs <- read_gtfs(spo_path)

ggl_gtfs <- read_gtfs(ggl_path)

merged_gtfs <- merge_gtfs(spo_gtfs, ggl_gtfs)

# use a list() to programatically merge many GTFS objects
gtfs_list <- list(spo_gtfs, ggl_gtfs)
merged_gtfs <- merge_gtfs(gtfs_list)

# 'prefix' helps disambiguating from which GTFS each id comes from.
# if TRUE, the ids range from 1:n, where n is the number of gtfs
merged_gtfs <- merge_gtfs(gtfs_list, prefix = TRUE)

# if a character vector, its elements will be used to identify the each gtfs
merged_gtfs <- merge_gtfs(gtfs_list, prefix = c("spo", "ggl"))

gtfstools documentation built on Nov. 24, 2022, 5:09 p.m.