Skip to contents

readCounts - Loads a MATSim Counts XML-file as tibble into memory

loadNetwork - Loads a MATSim XML network file, creating a nodes tibble and a links tibble. Any node and link attribute records in the network are stored as additional columns in the respective node and link tibbles.
The links table is automatically joined with the nodes table so that node x/y coordinates (and any other node attributes) are available on the links table without additional processing.

readPersonsTable - Loads a MATSim CSV output_persons from file or archive, creating a tibble with columns as in csv file copied + adopted code from readTripsTable in tripsOutput.R

boxplotScoreDifferences - function generates a boxplot to compare the score differences between two sets of data represented by personTibble_base and personTibble_policy tibbles. It provides insights into the distribution of score differences between the two sets of data.

These functions are provided for compatibility with older version of the matsimr package. They may eventually be completely removed.

plotModalSplitPieChart - Takes Table trips_output (from read_output_trips), to plot pie chart with with values that represent percentage of using transport modes from trips

plotModalSplitBarChart - Takes Table trips_output (from read_output_trips), to plot bar chart with with values that represent percentage of using transport modes from trips

readTripsTable - Loads a MATSim output_trips file from file or archive path, creating a tibble

plotAverageTravelWait - Takes Table trips_output (from read_output_trips), to plot bar chart with with values that represent time spent on traveling/waiting Using parameters unite.columns, specific columns could be given, to unite them in 1 mode with the name united_name(by default 'united')

plotModalDistanceDistribution - Takes Table trips_output (from read_output_trips), to plot bar chart with with values that represent number of trips ~ distance travelled Using parameters unite.columns, specific columns could be given, to unite them in 1 mode with the name united_name(by default 'united')

compareModalDistanceDistribution - Takes 2 Tables trips_output (from read_output_trips), to plot bar chart with with values that represent difference of number of trips between tripsTable2 and tripsTable1 ~ distance travelled Using parameters unite.columns, specific columns could be given, to unite them in 1 mode with the name united_name(by default 'united')

plotTripDistanceByMode - Takes Table trips_output (from read_output_trips), to plot bar chart with with values that represent average distance traveled ~ main mode used Using parameters unite.columns, specific columns could be given, to unite them in 1 mode with the name united_name(by default 'united')

plotTripCountByDepTime - Takes Table trips_output (from read_output_trips), to make line plot with with values that represent count of trips for a specific departure time by main_mode Using parameters unite.columns, specific columns could be given, to unite them in 1 mode with the name united_name(by default 'united')

plotActivityEndTimes - Takes Table trips_output (from read_output_trips), to make line plot with with values that represent the number of activities ending at a specific time. Using parameters unite.columns, specific columns could be given, to unite them in 1 mode with the name united_name(by default 'united')

plotArrivalTimesPerTripPurpose - Takes Table trips_output (from read_output_trips), to make line plot with with values that represent count of destination activities for a specific arrival time Using parameters unite.columns, specific columns could be given, to unite them in 1 mode with the name united_name(by default 'united')

plotDepartureTimesPerTripPurpose - Takes Table trips_output (from read_output_trips), to make line plot with with values that represent count of destination activities for a specific arrival time Using parameters unite.columns, specific columns could be given, to unite them in 1 mode with the name united_name(by default 'united')

plotTripDistancedByType - Takes Table trips_output (from read_output_trips), to plot bar chart with with values that represent travelled distance of each tripType related to the shapeTable

plotModalShiftSankey - Takes two trips_table (from read_output_trips), and collects changes between transport mode distribution of these tables to make alluvial diagram from this data
Function calculates number of each transport mode used in first and second table, and draws plot that represent how distribution of transport mode has changed (f. e. what part of concrete trasport mode changed to another) Using parameter unite.columns transport modes that match PATTERN in unite.columns can be united in 1 transport mode type (by default united_name is "united") Using parameter show.onlyChanges

plotModalShiftBar - Takes two trips_table (from read_output_trips), and collects changes between transport mode distribution of these tables to make bar chart diagram with dodging positioning from this data
Function calculates number of each transport mode used in first and second table, and draws plot that represent how distribution of transport mode has changed (f. e. what part of concrete trasport mode changed to another) Using parameter unite.columns transport modes that match PATTERN in unite.columns can be united in 1 transport mode type (by default united_name is "united") Using parameter show.onlyChanges

plotMapWithFilteredTrips - Takes trips_table and shapeTable(sf object from file representing geographical data, can be received by using function st_read(path_to_file)) transforms both objects to match mutual CRS(network.xml from MATSimOutputDirectory) and filters the trips from table depending on *.inshape flags:
if start.inshape = TRUE & end.inshape = TRUE return table that contains trips inside given shape
if start.inshape = TRUE & end.inshape = FALSE return table that contains trips which starts in shape and ends out of the shape
if start.inshape = FALSE & end.inshape = TRUE return table that contains trips which ends in shape and starts out of the shape
if start.inshape = FALSE & end.inshape = FALSE return table that contains trips which starts and ends our of the given shape
result of filtering is plotted on map of shapeTable where green points are startpoints of trip and red points are endpoints of trip

plotMapWithTrips - Plots start and end coordinates of the given trips table on an osm map

plotTripTypesPieChart - plots distribution of every type of trips(inside, outside, origin and destinating) in Pie Chart

compareTripTypesBarChart - Creates BarChart of changing trip types(originating,transit etc) between 2 tables and saves output to dump.output.to

plotMapWithTripsType - plots every type of trips(inside, outside, origin and destinating) on map

compareBasePolicyOutput - Chooses a function to compare output_trips from the folders. baseFolder contains all base outputs, policyFolder contains all policy outputs.

compareBasePolicyShapeOutput - Chooses a function to compare output_trips from the folders. baseFolder contains all base outputs, policyFolder contains all policy outputs.

appendDistanceCategory - adds to trips output tibble additional column that represent distance as category

filterByRegion - Filtering of trips_table(from read_output_trips) depending on how they located in given shape
Takes trips_table and shapeTable(sf object from file representing geographical data, can be received by using function st_read(path_to_file). Please be aware that this filterByRegion currently only works, when one geometry is loaded.) transforms both objects to match mutual CRS(network.xml from MATSimOutputDirectory) and filters the trips from table depending on *.inshape flags:
if start.inshape = TRUE & end.inshape = TRUE return table that contains trips inside given shape
if start.inshape = TRUE & end.inshape = FALSE return table that contains trips which starts in shape and ends out of the shape
if start.inshape = FALSE & end.inshape = TRUE return table that contains trips which ends in shape and starts out of the shape
if start.inshape = FALSE & end.inshape = FALSE return table that contains trips which starts and ends our of the given shape

deriveODMatrix - Creates an instance of ODMatrix(origin/destination) in conventional form or for the simwrapper

getCrsFromConfig - Reads an coordinate reference system of MATSim output directory from output_config.xml

transformToSf - Transforms trips_table tibble (from read_output_trips) from tibble to sf (table with attribute features and geometry feature)
Takes trips_table (from read_output_trips) and transforms trips_table to sf object using start_x, end_x, start_y, end_y as a geometry features deletes from resulting data.frame start_x, end_x, start_y, end_y.
And adds wkt column, if geometry.type = st_mulitpoint(), or geometry.type = st_linestring()
Or adds start_wkt and end_wkt, if geometry.type = st_point()
Added column/columns projected to given CRS (coordinate reference system), that can be taken from network file of MATSimOutputDirectory
Function also sets attribute geometry.type to resulting table to character value of "POINT","MULTIPOINT","LINESTRING" to get which type of table was generated, if it is needed

Takes Table trips_output (from readTripsTable()), to plot scatter plot with with values that represent count of start activities for a specific departure time by main_mode Using parameters unite.columns, specific columns could be given, to unite them in 1 mode with the name united.name(by default 'united')

Usage

readCounts(file)

loadNetwork(filename)

readPersonsTable(input_path = ".", n_max = Inf)

boxplotScoreDifferences(personTibble_base, personTibble_policy)

plotModalSplitPieChart(
  tripsTable,
  unite.columns = character(0),
  united.name = "united",
  dump.output.to = matsimDumpOutputDirectory,
  only.files = FALSE
)

plotModalSplitBarChart(
  tripsTable,
  unite.columns = character(0),
  united.name = "united",
  dump.output.to = matsimDumpOutputDirectory,
  only.files = FALSE
)

readTripsTable(input_path = ".", n_max = Inf)

plotAverageTravelWait(
  tripsTable,
  unite.columns = character(0),
  united.name = "united",
  dump.output.to = matsimDumpOutputDirectory,
  only.files = FALSE
)

compareAverageTravelWait(
  tripsTable1,
  tripsTable2,
  unite.columns = character(0),
  united.name = "united",
  dump.output.to = matsimDumpOutputDirectory,
  only.files = FALSE
)

plotModalDistanceDistribution(
  tripsTable,
  unite.columns = character(0),
  united.name = "united",
  dump.output.to = matsimDumpOutputDirectory,
  only.files = FALSE
)

compareModalDistanceDistribution(
  tripsTable1,
  tripsTable2,
  unite.columns = character(0),
  united.name = "united",
  dump.output.to = matsimDumpOutputDirectory,
  only.files = FALSE
)

plotTripDistanceByMode(
  tripsTable,
  unite.columns = character(0),
  united.name = "united",
  dump.output.to = matsimDumpOutputDirectory,
  only.files = FALSE
)

plotTripCountByDepTime(
  tripsTable,
  unite.columns = character(0),
  united.name = "united",
  dump.output.to = matsimDumpOutputDirectory,
  only.files = FALSE
)

plotActivityEndTimes(
  tripsTable,
  unite.columns = character(0),
  united.name = "united",
  dump.output.to = matsimDumpOutputDirectory,
  only.files = FALSE
)

plotArrivalTimesPerTripPurpose(
  tripsTable,
  unite.columns = character(0),
  united.name = "united",
  dump.output.to = matsimDumpOutputDirectory,
  only.files = FALSE
)

plotDepartureTimesPerTripPurpose(
  tripsTable,
  unite.columns = character(0),
  united.name = "united",
  dump.output.to = matsimDumpOutputDirectory,
  only.files = FALSE
)

plotTripDistancedByType(
  tripsTable,
  shapeTable,
  crs,
  dump.output.to = matsimDumpOutputDirectory
)

plotModalShiftSankey(
  tripsTable1,
  tripsTable2,
  show.onlyChanges = FALSE,
  unite.columns = character(0),
  united.name = "united",
  dump.output.to = matsimDumpOutputDirectory
)

plotModalShiftBar(
  tripsTable1,
  tripsTable2,
  unite.columns = character(0),
  united.name = "united",
  dump.output.to = matsimDumpOutputDirectory,
  output.name = "modalShiftBarChart"
)

plotMapWithFilteredTrips(
  table,
  shapeTable,
  crs,
  start.inshape = TRUE,
  end.inshape = TRUE,
  optimized = FALSE
)

plotMapWithTrips(table, crs, optimized = FALSE)

plotTripTypesPieChart(table, shapeTable, crs)

compareTripTypesBarChart(
  tripsTable1,
  tripsTable2,
  shapeTable,
  crs,
  dump.output.to = matsimDumpOutputDirectory
)

plotMapWithTripsType(table, shapeTable, crs, optimized = FALSE)

compareBasePolicyOutput(
  baseFolder,
  policyFolder,
  dump.output.to = matsimDumpOutputDirectory
)

compareBasePolicyShapeOutput(
  baseFolder,
  policyFolder,
  shapeFilePath,
  crs,
  dump.output.to = matsimDumpOutputDirectory
)

appendDistanceCategory(tripsTable)

filterByRegion(
  tripsTable,
  shapeTable,
  crs,
  start.inshape = TRUE,
  end.inshape = TRUE
)

deriveODMatrix(
  tripsTable,
  shapePath,
  crs,
  dump.output.to = matsimDumpOutputDirectory,
  simwrapper = FALSE,
  colnames = "numeric",
  outer = FALSE
)

getCrsFromConfig(folder)

transformToSf(table, crs, geometry.type = st_multipoint())

plotStartActCountByDepTime(
  tripsTable,
  unite.columns = character(0),
  united.name = "united",
  dump.output.to = matsimDumpOutputDirectory,
  only.files = FALSE
)

Arguments

file

File to load. Must be an .xml file

filename

File to load. Can be XML or gzipped XML

input_path

character string, path to MATSim output directory or http link to the file.

n_max

integer, maximum number of lines to read within output_trips

personTibble_base

persons tibble of the base case, can be loaded with readPersonsTable.

personTibble_policy

persons tibble of the policy case, can be loaded with readPersonsTable.

tripsTable

tible of trips_output (from readTripsTable())

unite.columns

vector of character strings, that represent patterns of columns to be united, changes name of all transport modes in the tibble copy to united.name = "united" that matches PATTERNS given in unite.columns

united.name

character string, if columns were united, you can specify name for the resulting column in chart

dump.output.to

folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored

only.files

boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly

tripsTable1

tibble of trips_output (from read_output_trips,f.e. base case)

tripsTable2

tibble of trips_output (from read_output_trips,f.e. policy case)

shapeTable

sf object(data.frame with geometries), can be received by using st_read(path_to_geographical_file)

crs

numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation

show.onlyChanges

boolean, if it is set to TRUE => sankey diagram only contains changes on axes

output.name

test

table

tibble of trips_output (from read_output_trips)

start.inshape

bool, defines trips to conclude (see Description)

end.inshape

bool, defines trips to conclude (see Description)

optimized

bool, by default FALSE and gives interactive plot using leaflet, if TRUE using image with ggplot

baseFolder

specifies data source folder with multiple base output_trips

policyFolder

specifies data source folder with multiple policy output_trips

shapeFilePath

specifies shapeFile used for comparison

shapePath

full path to shapefile (if simwrapper TRUE, folder with shapeFile should contain also .dbf with the same name)

simwrapper

create output in a simwrapper form if set to path of the shapefile

colnames

if the specific shapefile contains known columns, they could be specified as name for columns OD. If not given then they get numeric values

outer

logical that represent if the table should contain outside flow of the shape, it isn't

folder

specifies path to find config

geometry.type

function of sf transformation, geometry.type can be (by default is st_multipoint())
!!!st_point()-resulting table contains 2 geometries start_wkt and end_wkt, representing start and end POINTs, and have type POINT!!! or
!!!st_multipoint()-resulting table contains 1 geometry wkt, representing start and end POINTS as MULTIPOINT!!! or
!!!st_linestring() - resulting table contains 1 geometry wkt, representing line between start and end points as LINESTRING!!!

Value

readCounts - tibble with MATSim link id ("loc_id") as key

loadNetwork - "nodes" and "links" tibbles in a list object.

readPersonsTable - tibble of output_persons

boxplotScoreDifferences - ggplot boxplot of the distribution of the score differences

plotModalSplitPieChart - Pie Chart plot of transport mode distribution, values given in percents

plotModalSplitBarChart - Bar Chart plot of transport mode distribution, values given in percents

readTripsTable - tibble of output_trips

plotAverageTravelWait - Bar Chart plot of average time spent on travel/wait

plotModalDistanceDistribution Bar Chart plot of count of trips among distance travelled

compareModalDistanceDistribution - Bar Chart plot of count of trips among distance travelled

plotTripDistanceByMode - Bar Chart plot of distance traveled per mode

plotTripCountByDepTime - Line Chart plot of trips count by departure mode per mode

plotActivityEndTimes Line plot with departure time x-axis and number start activities on y-axis

plotArrivalTimesPerTripPurpose - Line plot with arrival time x-axis and number end activities on y-axis

plotDepartureTimesPerTripPurpose - Line plot with arrival time x-axis and number end activities on y-axis

plotTripDistancedByType - Bar Chart plot of distance traveled by type

plotModalShiftSankey - Alluvial diagram that represents changes in transport mode distribution of trip tables

plotModalShiftBar - plots Bar Chart of transport mode changes with additional files for simwrapper

plotMapWithFilteredTrips - plot with trips filtered depending on flags *.inshape on map from shapeTable

plotMapWithTrips - plot with trips

plotTripTypesPieChart - plot with percentage of each type of trips

compareTripTypesBarChart - plot with percentage of each type of trips between 2 tables

plotMapWithTripsType - plot that contains every trip with defined trip type

compareBasePolicyOutput - list of tibbles, list of all base and policy output_trips as tibble

compareBasePolicyShapeOutput - list of tibbles, list of all base and policy output_trips as tibble

tibble of output_trips with distance category column

filterByRegion - tibble, with filtered trips depending on shapeTable and special flags (see Description)

deriveODMatrix - tibble of origin/destination matrix

getCrsFromConfig - code of coordinate reference system

transformToSf - sf object (data.frame with geometries depending to geometry.type)

Bar Chart plot of distance traveled per mode

Details

plotModalSplitPieChart now a synonym for plot_mainmode_piechart
plotModalSplitBarChart now a synonym for plot_mainmode_barchart
plotAverageTravelWait now a synonym for plot_travelwaittime_mean_barchart
plotModalDistanceDistribution now a synonym for plot_distcat_by_mainmode_barchart
plotTripDistanceByMode now a synonym for plot_distance_by_mainmode_barchart
plotTripCountByDepTime now a synonym for plot_trips_count_by_deptime_and_mainmode_linechart
plotActivityEndTimes not part of package(contained false logic)
plotArrivalTimesPerTripPurposenow a synonym for plot_arrtime_by_act
plotDepartureTimesPerTripPurpose now a synonym for plot_deptime_by_act
plotTripTypesPieChart now a synonym for plot_spatialtype_by_shape_piechart
plotMapWithFilteredTripsnot part of package, you can filter before drawing a map
plotMapWithTripsnow a synonym for plot_map_trips
plotMapWithTripsType now a synonym for plot_map_trips_by_spatialcat
plotTripDistancedByType now a synonym for plot_distance_by_spatialcat_barchart
plotModalShiftBar now a synonym for plot_compare_mainmode_barchart
plotModalShiftSankey now a synonym for plot_compare_mainmode_sankey
compareAverageTravelWait now a synonym for plot_compare_travelwaittime_by_mainmode_barchart
compareTripTypesBarChartnow a synonym for plot_compare_count_by_spatialcat_barchart
compareModalDistanceDistribution now a synonym for plot_compare_distcat_by_mainmode_barchart
compareBasePolicyOutput is not used in new package version, and is prepared to be completely removed from package If you would like to keep it in new package, write at soboliev@campus.tu-berlin.de
compareBasePolicyShapeOutput is not used in new package version, and is prepared to be completely removed from package If you would like to keep it in new package, write at soboliev@campus.tu-berlin.de
appendDistanceCategorynow a synonym for process_append_distcat
filterByRegion now a synonym for process_filter_by_shape
deriveODMatrix now a synonym for process_get_od_matrix
getCrsFromConfignow a synonym for process_get_crs_from_config
transformToSf now a synonym for process_convert_table_to_sf
readTripsTablenow a synonym for read_output_trips
readConfig now a synonym for read_config