knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Overview

All function names are created following the same pattern. They start with a specific verb (e.g. read, plot, process) that describes their main function. They are sorted into [function types] according to this usage. This, and all following naming elements are followed by an underscore.

The second element is optional. It further specifies the type of action that is performed and can be used to distinguish similar functions. In the following guide this element is called [clarification]. An example for this element is [compare], which is used in all functions that compare two data sets.

The next element specifies the data or the columns used. For example the column [mainmode] or the MATSim file [output_trips].

If the data is going to be sorted or filtered it can be necessary to specify how. This is done using [by]. An example is the function [plot_arrtime_by_act]: it plots the column [arrtime], which contains the arrival time, by [act] or activity. Several of these can be connected using [and].

The last element can be used to specify the output type. This is important for the plotting functions where it specifies the type of plot.

Template

So to summarize, every naming template looks similar to:

[function_type]_{clarification}_[data]_{by}_{category}_{and}_..._{output_type}

[function_type]: Describes the type of the function, indicating its primary purpose or operation. For example, "plot" to plot functions, "process" for data processing functions, "read" for functions that read data into the R environment.

{clarification}: This part is optional and provides additional details or clarification about the function's purpose and behavior. It helps to distinguish similar functions and variations of the same function. For example, "compare" to indicate that the function performs a comparison, "append" to indicate that the function appends data, etc.

For plotting functions:

For processing functions:

[data]: Refers to the file or column that the function is handling or manipulating. Examples include "arrtime" (arrival time), "distance" (distance traveled), "mainmode" (main transportation mode). Can be read with the function str().

{by}: This part is optional and indicates that the data is filtered or grouped by a specific category or factor. It serves as a connector between the [data] and [category] components.

{category}: Indicates a specific category or grouping factor that is used to filter or categorize the data. Examples include "act" (activity), "spatialcat" (spatial category), "mainmode" (main transportation mode).

{and}: This part is optional and is used as a connector if there are multiple categories involved in the function's operation.

{output_type}: Indicates the type of output or result that the function generates. It indicates the format or form of the data returned by the function. Examples include "barchart," "piechart," "linechart," "table".

Examples



matsim-vsp/matsim-r documentation built on Feb. 3, 2025, 6:48 p.m.