diff --git a/.gitignore b/.gitignore index fdf97db..2fc2883 100644 --- a/.gitignore +++ b/.gitignore @@ -35,4 +35,6 @@ network.xml.gz analysis_berlin10/ kelheim/ test/ +dashboard_test/ .sentinel* +inst/doc diff --git a/DESCRIPTION b/DESCRIPTION index ad35c47..b21ecda 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: matsim Type: Package Title: R library for interfacing with MATSim agent-based microsimulation model -Version: 0.1.9 +Version: 0.2.0 Authors@R: c( person("Billy", "Charlton", email = "charlton@vsp.tu-berlin.de", role=c("aut","cre")), person("Oleksandr", "Soboliev", role="aut")) @@ -11,10 +11,10 @@ Description: MATSim support package for R of the Python matsim-tools package, and thus supports reading standard MATSim networks and soon, plans and events as well. . - Developed with support from the Technische Universität Berlin's + Developed with support from the Technische Universität Berlin's VSP Transport Planning and Transport Telematics department. . - This project is under ongoing development and submissions are welcome! + This project is under ongoing development and submissions are welcome! License: GPL (>= 3) Encoding: UTF-8 Imports: @@ -42,5 +42,8 @@ URL: https://github.com/matsim-vsp/matsim-r BugReports: https://github.com/matsim-vsp/matsim-r/issues RoxygenNote: 7.2.3 Suggests: + knitr, + rmarkdown, testthat (>= 3.0.0) Config/testthat/edition: 3 +VignetteBuilder: knitr diff --git a/Makefile b/Makefile index a67f997..2e9a6d7 100644 --- a/Makefile +++ b/Makefile @@ -29,4 +29,5 @@ docs: .sentinel-make-docs clean: > rm -rf docs > rm -rf man +> rm .sentinel* .PHONY: clean diff --git a/NAMESPACE b/NAMESPACE index ff824b3..ec0ce8f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,5 +1,6 @@ # Generated by roxygen2: do not edit by hand +export(appendDistanceCategory) export(boxplotScoreDifferences) export(compareAverageTravelWait) export(compareBasePolicyOutput) @@ -11,7 +12,6 @@ export(deriveODMatrix) export(filterByRegion) export(generateXYHexagonYaml) export(getCrsFromConfig) -export(loadNetwork) export(mergeCountsAndLinks) export(plotActivityEndTimes) export(plotArrivalTimesPerTripPurpose) @@ -29,22 +29,57 @@ export(plotTripCountByDepTime) export(plotTripDistanceByMode) export(plotTripDistancedByType) export(plotTripTypesPieChart) +export(plot_arrtime_by_act) +export(plot_compare_count_by_spatialcat_barchart) +export(plot_compare_distcat_by_mainmode_barchart) +export(plot_compare_mainmode_barchart) +export(plot_compare_mainmode_sankey) +export(plot_compare_score_boxplot) +export(plot_compare_travelwaittime_by_mainmode) +export(plot_compare_travelwaittime_by_mainmode_barchart) +export(plot_deptime_by_act) +export(plot_distance_by_mainmode_barchart) +export(plot_distance_by_spatialcat_barchart) +export(plot_distcat_by_mainmode_barchart) +export(plot_mainmode_barchart) +export(plot_mainmode_piechart) +export(plot_map_trips) +export(plot_map_trips_by_spatialcat) +export(plot_spatialtype_by_shape_piechart) +export(plot_travelwaittime_mean_barchart) +export(plot_trips_count_by_deptime_and_mainmode_linechart) export(prepareComparisonSimwrapperDashboardFromTable) export(prepareSimwrapperDashboardFromFolder) export(prepareSimwrapperDashboardFromTable) export(processDtvEstimationQuality) export(processLinkStatsDtvDistribution) +export(process_append_distcat) +export(process_append_spatialcat) +export(process_convert_table_to_sf) +export(process_convert_time) +export(process_filter_by_shape) +export(process_get_crs_from_config) +export(process_get_mainmode_distribution) +export(process_get_od_matrix) +export(process_get_travdistance_distribution) +export(process_get_travelwaittime_by_mainmode) +export(process_rename_category) +export(process_rename_mainmodes) export(readCounts) export(readLinkStats) export(readPersonsTable) export(readTripsTable) +export(read_config) +export(read_network) +export(read_output_persons) +export(read_output_trips) export(symlog_trans) export(transformToSf) import(dplyr) import(forcats) import(geomtextpath) import(ggalluvial) -import(ggplot2) +import(ggplot2, except = last_plot) import(ggrepel) import(htmltools) import(leaflet) @@ -52,10 +87,10 @@ import(lubridate) import(plotly) import(purrr) import(readr) -import(reshape) -import(scales) +import(reshape, except = c(stamp,rename,expand)) +import(scales, except = c(discard, col_factor)) import(sf) -import(tidyr) +import(tidyr, except = expand) import(tidyverse) import(xml2) import(yaml) diff --git a/R/config.R b/R/config.R new file mode 100644 index 0000000..c4e1d93 --- /dev/null +++ b/R/config.R @@ -0,0 +1,42 @@ +#' Load MATSIM config file into Memory +#' +#' Loads a MATSim xml config from file or archive, +#' creating a list with parameters as in xml file +#' +#' @param input_path character string, path to matsim output directory or http link to the file. +#' @param n_max integer, maximum number of lines to read within output_trips +#' @return tibble of trips_output +#' +#' @export +read_config <- function(input_path = ".", n_max = Inf) { + + result_tibble <- tibble(module = character(), + param = character(), + value = character()) + + config_xml<-read_xml(input_path) + + module_nodeset<-xml_children(config_xml) + + result_list <- list() + + for(i in 1:length(module_nodeset)){ + module_name = xml_attr(module_nodeset[[i]],"name") + + param_nodeset = xml_children(module_nodeset[[i]]) + for(j in 1:length(param_nodeset)){ + param_name<-xml_attr(param_nodeset[[j]],"name") + value_name<-xml_attr(param_nodeset[[j]],"value") + #print(param_name,value_name) + + result_list[[module_name]][[param_name]] <- value_name + + + } + + } + + return(result_list) + + +} diff --git a/R/counts.R b/R/counts.R index 0d3b0a4..f48b85c 100644 --- a/R/counts.R +++ b/R/counts.R @@ -1,5 +1,5 @@ #'@import tidyverse -#'@import scales +#' @rawNamespace import(scales, except = c(discard, col_factor)) #'@import xml2 #'@import geomtextpath #'@import readr @@ -8,12 +8,12 @@ #' #'@title Load a MATSim Counts file into memory #' -#'@description Loads a MATSim Counts XML-File as tibble into memory +#'@description Loads a MATSim Counts XML-file as tibble into memory #' #' #'@param file File to load. Must be an .xml file #' -#'@return tibble containing with MATSim Link id as "loc_id" as key +#'@return tibble with MATSim link id ("loc_id") as key #' #'@export readCounts <- function(file){ @@ -51,11 +51,11 @@ readCounts <- function(file){ result } -#' Load linkstats as tibble into memory +#' Load a MATSim linkstats file into memory #' -#' Reads Linkstats as .tsv created from LinkStats.class -#' as dataframe into memory. -#' Counts can be provided in any time bins. +#' Loads a linkstats tsv file created from the LinkStats class +#' as a dataframe into memory. +#' Counts can be provided in any time bin. #' Counts can be provided for any qsim mode. The argument networkModes is used to #' select and filter the columns. #' @@ -107,30 +107,30 @@ readLinkStats <- function(runId, file, sampleSize = 0.25){ } -#' Load Counts, a limited number of Linkstats and Network links as joined tibble into memory +#' Join counts and linkstats to the network, creating a tibble into memory #' -#'Function to join counts, network links and several matsim link stats. Data can be aggregated -#'and filtered by time or network mode. +#'Function to join counts, linkstats and network links. Data can be aggregated +#'and filtered by time or mode. #' #' #'@param counts Tibble with counts data #' #'@param network Tibble with network nodes and links #' -#'@param linkStats List with link stats tibbles +#'@param linkStats List with linkstats tibbles #' -#'@param networkModes a vector with network modes, which are needed for analysis +#'@param networkModes Vector with network modes that will be analyzed, default is "car". #' -#'@param aggr_to Determinates if data should be aggregated to hour values or DTV, can either be "day" or "hour" +#'@param aggr_to Determines if data should be aggregated into hourly bins or as daily traffic volume, can either be "day" or "hour" #' -#'@param earliest Lower limit to filter link stats by time, default is 0 +#'@param earliest Integer. Lower limit to filter link stats by time, default = 0. #' -#'@param latest Upper limit to filter link stats by time, default is 86400 (midnight) -#' -#'@return Long-format tibble with MATSim link id as key ("loc_id"), traffic volume from MATSim runs and link type +#'@param latest Integer. Upper limit to filter link stats by time, default = 86400 (midnight). #' +#'@return Long-format tibble with MATSim link id as key ("loc_id"), traffic volumes from MATSim runs and link type #' #'@export + mergeCountsAndLinks <- function(counts, network, linkStats, networkModes = c("car"), aggr_to = c("day", "hour"), earliest = 0, latest = 86400){ if(!is.list(linkStats)){ @@ -242,7 +242,7 @@ mergeCountsAndLinks <- function(counts, network, linkStats, networkModes = c("ca join.long } -#' Categorize DTV and calculate DTV distribution +#' Categorize daily traffic volume (DTV) and calculate DTV for different link types. #' #' Takes a tibble from mergeCountsAndLinks. DTV is categorized into bins. Finally #' data is aggregated to calculate DTV distribution in each link type category, @@ -252,13 +252,13 @@ mergeCountsAndLinks <- function(counts, network, linkStats, networkModes = c("ca #' #' @param joinedFrame A tibble from mergeCountsAndLinks #' -#' @param from Lower limit for count bin +#' @param from Integer. Lower limit for count bin, default = 0. #' -#' @param to Upper limit for count bins +#' @param to Integer. Upper limit for count bins, default = 40000. #' -#' @param by Size of each count bin +#' @param by Integer. Size of each count bin, default = 5000. #' -#' @return A long-format tibble which contains share of DTV Categories +#' @return A long-format tibble which contains share of DTV for link types #' #' @export processLinkStatsDtvDistribution <- function(joinedFrame, from = 0, to = 40000, by = 5000){ @@ -311,17 +311,16 @@ processLinkStatsDtvDistribution <- function(joinedFrame, from = 0, to = 40000, b #' Categorize DTV deviation and aggregate data #' #' Takes a tibble from mergeCountsAndLinks. -#' Deviation between count volumes and Linkstats is calculated -#' (e.g. deviation of 1.2 means 20 percent more DTV in MATSim than in counts) and -#' categorized. +#' Deviation between count volumes and Linkstats is calculated and +#' categorized (i.e. deviation of 1.2 means 20 percent more DTV in MATSim than in counts). #' If parameter 'aggr' is set to TRUE, data will be aggregated for each run and link type. #' Can be used to visualize model quality by link type and to compare several runs. #' -#' Estimation quality is determinated by the 'cut' function, limits for the label -#' 'exact' can be adjusted by tuning the parameter 'll' and 'ul' +#' Estimation quality is determined by the 'cut' function, limits for the label +#' 'exact' can be adjusted by tuning the parameters 'll' (lower limit) and 'ul' (upper limit) #' #' @param joinedFrame A tibble from mergeCountsAndLinks -#' @param aggr Boolean, if categorized data should returned aggregated +#' @param aggr Boolean, if categorized data should returned aggregated, default is TRUE. #' @param ll Formula to calculate lower limit of the quality label 'exact', default = 0.8*x - 200 #' @param ul Formula to calculate lower limit of the quality label 'exact', default = 1.2*x + 200 #' @@ -341,8 +340,8 @@ processDtvEstimationQuality <- function(joinedFrame, aggr = TRUE, ll = ~ x *0.8 join.1 <- joinedFrame %>% mutate(ll = ifelse(ll < 0, 0, ll), estimation = ifelse(volume < ll, "less", - ifelse(volume > ul, "more", - "exact")), + ifelse(volume > ul, "more", + "exact")), estimation = factor(estimation, levels = c("less", "exact", "more"))) if(aggr){ @@ -361,12 +360,12 @@ processDtvEstimationQuality <- function(joinedFrame, aggr = TRUE, ll = ~ x *0.8 #' Creates a Via-Style scatterplot for each run #' #' Takes a tibble from mergeCountsAndLinks. -#' A scatterplot with counts on the x axis and matsim dtv on the y axis is created and colored +#' A scatterplot with counts on the x axis and MATSim dtv on the y axis is created and colored #' by the road type. -#' Lower and upper Limits define the section which is considered as an 'exact' estimation. Limits +#' Lower and upper limits define the section which is considered an 'exact' estimation. Limits #' are defined by custom formulas. #' -#' The function calls the matsim-r function processDtvEstimationQuality which is handeling the limits. +#' The function calls the matsim-r function processDtvEstimationQuality which is handling the limits. #' #' @param joinedFrame A tibble from mergeCountsAndLinks #' @param ll Formula to calculate lower limit of the quality label 'exact', default = 0.8*x - 200 diff --git a/R/network.R b/R/network.R index f5dce53..80fc5c7 100644 --- a/R/network.R +++ b/R/network.R @@ -19,15 +19,15 @@ #' @import ggalluvial #' @import ggrepel #' @import tidyverse -#' @import tidyr -#' @import ggplot2 +#' @rawNamespace import(tidyr, except = expand) +#' @rawNamespace import(ggplot2, except = last_plot) #' @import yaml #' @import plotly #' @import leaflet #' @import forcats #' @import lubridate #' @import htmltools -#' @import reshape +#' @rawNamespace import(reshape, except = c(stamp,rename,expand)) # NETWORK = "kelheim.output_network.xml" # NETWORK = "network.xml" @@ -45,7 +45,7 @@ utils::globalVariables(c("name")) #' 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 +#' node x/y coordinates (and any other node attributes) are available in the #' links table without additional processing. #' #' @param filename File to load. Can be XML or gzipped XML @@ -53,7 +53,143 @@ utils::globalVariables(c("name")) #' @return "nodes" and "links" tibbles in a list object. #' #' @export +read_network <- function(filename) { + cat(filename, ": ") + network <- read_xml(filename) + + cat("Nodes..") + node_elements <- network %>% xml_find_all("./nodes/node") + nodes <- tibble( + id = node_elements %>% xml_attr("id"), + x = node_elements %>% xml_attr("x") %>% parse_double(), + y = node_elements %>% xml_attr("y") %>% parse_double(), + ) + + attributes <- node_elements %>% xml_find_all("./attributes/attribute") + # skip if there are no node attributes + if (length(attributes)) { + attrIds <- tibble(id = unlist(map(attributes, function(row) xml_attr(xml_parent(xml_parent(row)), "id")))) + + nodeAttributes <- tibble( + id = attrIds$id, + name = attributes %>% xml_attr("name"), + class = attributes %>% xml_attr("class"), + value = attributes %>% xml_text(), + ) + + # which columns should be converted to numeric? + types <- nodeAttributes %>% + select(name, class) %>% + distinct() + convert <- filter(types, class == "java.lang.Double")$name + + # convert to a format we can join to the links + nodeAttributes <- (nodeAttributes + %>% select(-class) + %>% pivot_wider(names_from = "name", values_from = "value") + %>% mutate_at(vars(one_of(convert)), as.double) + ) + nodes <- nodes %>% left_join(nodeAttributes, by = "id") + } + + cat("Links..") + link_elements <- network %>% xml_find_all("./links/link") + links <- tibble( + id = link_elements %>% xml_attr("id"), + from = link_elements %>% xml_attr("from"), + to = link_elements %>% xml_attr("to"), + length = link_elements %>% xml_attr("length") %>% parse_double(), + freespeed = link_elements %>% xml_attr("freespeed") %>% parse_double(), + capacity = link_elements %>% xml_attr("capacity") %>% parse_double(), + permlanes = link_elements %>% xml_attr("permlanes") %>% parse_double(), + modes = link_elements %>% xml_attr("modes"), + origid = link_elements %>% xml_attr("origid") + ) + + # merge node coordinates + links <- (links + %>% left_join(nodes, by = c("from" = "id")) + %>% left_join(nodes, by = c("to" = "id"), suffix = c(".from", ".to")) + ) + + # attributes don't have IDs on them! JFC, MATSim! + cat("Attributes..") + + attributes <- link_elements %>% xml_find_all("./attributes/attribute") + # skip if there are no link-attributes + if (length(attributes)) { + attrIds <- tibble(id = unlist(map(attributes, function(row) xml_attr(xml_parent(xml_parent(row)), "id")))) + + linkAttributes <- tibble( + id = attrIds$id, + name = attributes %>% xml_attr("name"), + class = attributes %>% xml_attr("class"), + value = attributes %>% xml_text(), + ) + + # which columns should be converted to numeric? + types <- linkAttributes %>% + select(name, class) %>% + distinct() + convert <- filter(types, class == "java.lang.Double")$name + + # convert to a format we can join to the links + linkAttributes <- (linkAttributes + %>% select(-class) + %>% pivot_wider(names_from = "name", values_from = "value") + %>% mutate_at(vars(one_of(convert)), as.double) + ) + + links <- links %>% left_join(linkAttributes, by = "id", suffix = c(".link", ".attr")) + } + + # Top-level network attributes + networkAttributes <- NULL + + allNetworkAttributes <- network %>% xml_find_all("./attributes/attribute") + if (length(allNetworkAttributes)) { + networkAttributes <- tibble( + name = allNetworkAttributes %>% xml_attr("name"), + class = allNetworkAttributes %>% xml_attr("class"), + value = allNetworkAttributes %>% xml_text(), + ) + # which columns should be converted to numeric? + types <- networkAttributes %>% + select(name, class) %>% + distinct() + convert <- filter(types, class == "java.lang.Double")$name + + # convert to a format we can join to the links + networkAttributes <- (networkAttributes + %>% select(-class) + %>% pivot_wider(names_from = "name", values_from = "value") + %>% mutate_at(vars(one_of(convert)), as.double) + ) + } + + cat("Done!\n") + + list("nodes" = nodes, "links" = links, "attributes" = networkAttributes) +} + + +#' Load MATSim network into memory +#' +#' \strong{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.\cr +#' 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. +#' +#' @rdname matsimr-deprecated +#' +#' @param filename File to load. Can be XML or gzipped XML +#' +#' @return \strong{loadNetwork} - "nodes" and "links" tibbles in a list object. +#' loadNetwork <- function(filename) { + .Deprecated("read_network") cat(filename, ": ") network <- read_xml(filename) @@ -85,9 +221,9 @@ loadNetwork <- function(filename) { # convert to a format we can join to the links nodeAttributes <- (nodeAttributes - %>% select(-class) - %>% pivot_wider(names_from = "name", values_from = "value") - %>% mutate_at(vars(one_of(convert)), as.double) + %>% select(-class) + %>% pivot_wider(names_from = "name", values_from = "value") + %>% mutate_at(vars(one_of(convert)), as.double) ) nodes <- nodes %>% left_join(nodeAttributes, by = "id") } @@ -108,8 +244,8 @@ loadNetwork <- function(filename) { # merge node coordinates links <- (links - %>% left_join(nodes, by = c("from" = "id")) - %>% left_join(nodes, by = c("to" = "id"), suffix = c(".from", ".to")) + %>% left_join(nodes, by = c("from" = "id")) + %>% left_join(nodes, by = c("to" = "id"), suffix = c(".from", ".to")) ) # attributes don't have IDs on them! JFC, MATSim! @@ -135,9 +271,9 @@ loadNetwork <- function(filename) { # convert to a format we can join to the links linkAttributes <- (linkAttributes - %>% select(-class) - %>% pivot_wider(names_from = "name", values_from = "value") - %>% mutate_at(vars(one_of(convert)), as.double) + %>% select(-class) + %>% pivot_wider(names_from = "name", values_from = "value") + %>% mutate_at(vars(one_of(convert)), as.double) ) links <- links %>% left_join(linkAttributes, by = "id", suffix = c(".link", ".attr")) @@ -161,9 +297,9 @@ loadNetwork <- function(filename) { # convert to a format we can join to the links networkAttributes <- (networkAttributes - %>% select(-class) - %>% pivot_wider(names_from = "name", values_from = "value") - %>% mutate_at(vars(one_of(convert)), as.double) + %>% select(-class) + %>% pivot_wider(names_from = "name", values_from = "value") + %>% mutate_at(vars(one_of(convert)), as.double) ) } diff --git a/R/output_persons.R b/R/output_persons.R new file mode 100644 index 0000000..56677c7 --- /dev/null +++ b/R/output_persons.R @@ -0,0 +1,196 @@ +matsimDumpOutputDirectory <- "./matsim_r_output" +dashboard_file <- "/dashboard-1-trips.yaml" + + +#' Deprecated Function +#' +#' \strong{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 +#' +#' @rdname matsimr-deprecated +#' +#' @param input_path is a character string, path to the local MATSim output directory, to the persons csv directly, or a http link to the file. +#' @param n_max integer, maximum number of lines to read within output_persons + +#' @return \strong{readPersonsTable} - tibble of output_persons +#' +#' @export +readPersonsTable <- function(input_path = ".", n_max = Inf) { + .Deprecated("read_output_persons") + options(digits = 18) + + persons_file <- "" + + if(dir.exists(input_path)){ + files <- list.files(input_path, full.names = TRUE) + person_file_indicies <- grep("output_persons.csv.gz$", files) + + if(length(person_file_indicies) == 1){ + persons_file <- files[person_file_indicies] + } else { + stop('There is supposed to be a single "output_persons.csv.gz" found in directory') + } + } else { + persons_file <- input_path + } + + persons_output_table <- read_delim(persons_file, + delim = ";", + locale = locale(decimal_mark = "."), + n_max = n_max, + col_types = cols( + executed_score = col_character(), + first_act_x = col_character(), + first_act_y = col_character(), + first_act_type = col_character(), + ) + ) + + persons_output_table <- persons_output_table %>% + mutate( + executed_score = as.double(executed_score), + first_act_x = as.double(first_act_x), + first_act_y = as.double(first_act_y), + ) + + attr(persons_output_table,"table_name") <- input_path + + return(persons_output_table) +} + +#' Load MATSim output_persons table into memory +#' +#' 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 +#' +#' @param input_path is a character string, path to the local MATSim output directory, to the persons csv directly, or a http link to the file. +#' @param n_max integer, maximum number of lines to read within output_persons + +#' @return tibble of output_persons +#' +#' @export +read_output_persons <- function(input_path = ".", n_max = Inf) { + options(digits = 18) + + persons_file <- "" + + if(dir.exists(input_path)){ + files <- list.files(input_path, full.names = TRUE) + person_file_indicies <- grep("output_persons.csv.gz$", files) + + if(length(person_file_indicies) == 1){ + persons_file <- files[person_file_indicies] + } else { + stop('There is supposed to be a single "output_persons.csv.gz" found in directory') + } + } else { + persons_file <- input_path + } + + persons_output_table <- read_delim(persons_file, + delim = ";", + locale = locale(decimal_mark = "."), + n_max = n_max, + col_types = cols( + executed_score = col_character(), + first_act_x = col_character(), + first_act_y = col_character(), + first_act_type = col_character(), + ) + ) + + persons_output_table <- persons_output_table %>% + mutate( + executed_score = as.double(executed_score), + first_act_x = as.double(first_act_x), + first_act_y = as.double(first_act_y), + ) + + attr(persons_output_table,"table_name") <- input_path + + return(persons_output_table) +} +#' Deprecated Function +#' +#' \strong{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. +#' +#' @rdname matsimr-deprecated +#' +#' @param personTibble_base persons tibble of the base case, can be loaded with readPersonsTable. +#' @param personTibble_policy persons tibble of the policy case, can be loaded with readPersonsTable. +#' +#' @return \strong{boxplotScoreDifferences} - ggplot boxplot of the distribution of the score differences +#' +#' @export +boxplotScoreDifferences <- function(personTibble_base, personTibble_policy){ + + joined <- inner_join(personTibble_base, personTibble_policy, by = "person", suffix = c("_base", "_policy")) %>% + select(person, + executed_score_base, + executed_score_policy) %>% + mutate(score_diff = executed_score_policy - executed_score_base) + + result <- ggplot(joined, aes(y = score_diff)) + + geom_boxplot(fill = "#0099f8") + + labs( + title = "Distribution of score differences", + subtitle = "score_delta = score(policy) - score(base)", + #caption = "Source: MTCars dataset", + y = "score_delta" + ) + + theme_classic() + + theme( + plot.title = element_text(color = "#0099f8", size = 16, face = "bold", hjust = 0.5), + plot.subtitle = element_text(face = "bold.italic", hjust = 0.5), + plot.caption = element_text(face = "italic"), + axis.ticks.x = element_blank(), + axis.title.x = element_blank(), + axis.text.x = element_blank() + ) + result +} + + +#' Boxplot of Score Differences +#' +#' The \code{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. +#' +#' @param personTibble_base persons tibble of the base case, can be loaded with readPersonsTable. +#' @param personTibble_policy persons tibble of the policy case, can be loaded with readPersonsTable. +#' +#' @return ggplot boxplot of the distribution of the score differences +#' +#' @export +plot_compare_score_boxplot <- function(personTibble_base, personTibble_policy){ + + joined <- inner_join(personTibble_base, personTibble_policy, by = "person", suffix = c("_base", "_policy")) %>% + select(person, + executed_score_base, + executed_score_policy) %>% + mutate(score_diff = executed_score_policy - executed_score_base) + + result <- ggplot(joined, aes(y = score_diff)) + + geom_boxplot(fill = "#0099f8") + + labs( + title = "Distribution of score differences", + subtitle = "score_delta = score(policy) - score(base)", + #caption = "Source: MTCars dataset", + y = "score_delta" + ) + + theme_classic() + + theme( + plot.title = element_text(color = "#0099f8", size = 16, face = "bold", hjust = 0.5), + plot.subtitle = element_text(face = "bold.italic", hjust = 0.5), + plot.caption = element_text(face = "italic"), + axis.ticks.x = element_blank(), + axis.title.x = element_blank(), + axis.text.x = element_blank() + ) + result +} diff --git a/R/output_trips.R b/R/output_trips.R new file mode 100644 index 0000000..0c9c0d4 --- /dev/null +++ b/R/output_trips.R @@ -0,0 +1,4116 @@ +#####Variables#### + +matsimDumpOutputDirectory <- "./matsim_r_output" +dashboard_file <- "/dashboard-1-trips.yaml" + + + + +#####Deprecated#### + + + + +#' Deprecated function(s) in the matsimr package +#' +#' +#' These functions are provided for compatibility with older version of +#' the matsimr package. They may eventually be completely +#' removed.\cr\cr +#' \strong{plotModalSplitPieChart} - Takes Table trips_output (from \link{read_output_trips}), +#' to plot pie chart with with values that represent +#' percentage of using transport modes from trips +#' +#' @rdname matsimr-deprecated +#' @name matsimr-deprecated +#' +#' +#' @param tripsTable tible of trips_output (from \link{read_output_trips}) +#' @param 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 +#' @param united.name character string, if columns were united, you can specify name for the resulting column in chart +#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored +#' @param only.files boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly +#' +#' @return \strong{plotModalSplitPieChart} - Pie Chart plot of transport mode distribution, values given in percents +#' +#' @docType package +#' @export plotModalSplitPieChart +#' @aliases plotModalSplitPieChart +#' @section Details: +#' \code{plotModalSplitPieChart} now a synonym for \code{\link{plot_mainmode_piechart}}\cr +#' \code{plotModalSplitBarChart} now a synonym for \code{\link{plot_mainmode_barchart}}\cr +#' \code{plotAverageTravelWait} now a synonym for \code{\link{plot_travelwaittime_mean_barchart}}\cr +#' \code{plotModalDistanceDistribution} now a synonym for \code{\link{plot_distcat_by_mainmode_barchart}}\cr +#' \code{plotTripDistanceByMode} now a synonym for \code{\link{plot_distance_by_mainmode_barchart}}\cr +#' \code{plotTripCountByDepTime} now a synonym for \code{\link{plot_trips_count_by_deptime_and_mainmode_linechart}}\cr +#' \code{plotActivityEndTimes} not part of package(contained false logic)\cr +#' \code{plotArrivalTimesPerTripPurpose}now a synonym for \code{\link{plot_arrtime_by_act}}\cr +#' \code{plotDepartureTimesPerTripPurpose} now a synonym for \code{\link{plot_deptime_by_act}}\cr +#' \code{plotTripTypesPieChart} now a synonym for \code{\link{plot_spatialtype_by_shape_piechart}}\cr +#' \code{plotMapWithFilteredTrips}not part of package, you can filter before drawing a map\cr +#' \code{plotMapWithTrips}now a synonym for \code{\link{plot_map_trips}}\cr +#' \code{plotMapWithTripsType} now a synonym for \code{\link{plot_map_trips_by_spatialcat}}\cr +#' \code{plotTripDistancedByType} now a synonym for \code{\link{plot_distance_by_spatialcat_barchart}}\cr +#' \code{plotModalShiftBar} now a synonym for \code{\link{plot_compare_mainmode_barchart}}\cr +#' \code{plotModalShiftSankey} now a synonym for \code{\link{plot_compare_mainmode_sankey}}\cr +#' \code{compareAverageTravelWait} now a synonym for \code{\link{plot_compare_travelwaittime_by_mainmode_barchart}}\cr +#' \code{compareTripTypesBarChart}now a synonym for \code{\link{plot_compare_count_by_spatialcat_barchart}}\cr +#' \code{compareModalDistanceDistribution} now a synonym for \code{\link{plot_compare_distcat_by_mainmode_barchart}}\cr +#' \code{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 \strong{soboliev@campus.tu-berlin.de}\cr +#' \code{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 \strong{soboliev@campus.tu-berlin.de}\cr +#' \code{appendDistanceCategory}now a synonym for \code{\link{process_append_distcat}}\cr +#' \code{filterByRegion} now a synonym for \code{\link{process_filter_by_shape}}\cr +#' \code{deriveODMatrix} now a synonym for \code{\link{process_get_od_matrix}}\cr +#' \code{getCrsFromConfig}now a synonym for \code{\link{process_get_crs_from_config}}\cr +#' \code{transformToSf} now a synonym for \code{\link{process_convert_table_to_sf}}\cr +#' \code{readTripsTable}now a synonym for \code{\link{read_output_trips}}\cr +#' \code{readConfig} now a synonym for \code{\link{read_config}}\cr +#' +plotModalSplitPieChart <- function(tripsTable, + unite.columns = character(0), united.name = "united", + dump.output.to = matsimDumpOutputDirectory, + only.files = FALSE) { + + .Deprecated("plot_mainmode_piechart") + # If some columns should be united + if (length(unite.columns) != 0) { + tripsTable$main_mode[grep(paste0(unite.columns, collapse = "|"), tripsTable$main_mode)] <- united.name + } + + # calculates the mode share and saves it as a tibble + tripsTableCount <- tripsTable %>% + count(main_mode) %>% + mutate(n = n / sum(n) * 100) + + # getthe positions + positions <- tripsTableCount %>% + mutate( + csum = rev(cumsum(rev(n))), + pos = n / 2 + lead(csum, 1), + pos = if_else(is.na(pos), n / 2, pos) + ) + + # plotting + + plt <- ggplot(tripsTableCount, aes(x = "", y = n, fill = main_mode)) + + geom_bar(stat = "identity", width = 1) + + coord_polar("y", start = 0) + + geom_label_repel( + data = positions, + aes(y = pos, label = paste0(round(n, digits = 1), "%")), + size = 4.5, nudge_x = 1, show.legend = FALSE + ) + + ggtitle("Distribution of transport type") + + theme_void() + plt + + if (file.exists(dump.output.to)) { + ggsave(paste0(dump.output.to, "/modalSplitPieChart.png"),width = 6,height = 10, plt) + } else { + dir.create(dump.output.to) + ggsave(paste0(dump.output.to, "/modalSplitPieChart.png"),width = 6,height = 10, plt) + } + + # Generating yaml and output_files + if (file.exists(dump.output.to)) { + write_file(paste(tripsTableCount$main_mode, collapse = "\t"), paste0(dump.output.to, "/modalSplitPieChart.txt"), append = FALSE) + write_file(paste("\r\n", paste(tripsTableCount$n, collapse = "\t")), paste0(dump.output.to, "/modalSplitPieChart.txt"), append = TRUE) + # write.csv2(tripsTableCount,paste0(matsimDumpOutputDirectory,"/modalSplitPieChart.csv")) + } else { + dir.create(dump.output.to) + write_file(paste(tripsTableCount$main_mode, collapse = "\t"), paste0(dump.output.to, "/modalSplitPieChart.txt"), append = FALSE) + write_file(paste("\r\n", paste(tripsTableCount$n, collapse = "\t")), paste0(dump.output.to, "/modalSplitPieChart.txt"), append = TRUE) + # write.csv2(tripsTableCount,paste0(matsimDumpOutputDirectory,"/modalSplitPieChart.csv")) + } + + yaml_list <- list( + header = list(tab = "Summary", title = "Dashboard", description = "Plots from output directory"), + layout = list("1" = list( + title = paste0("Modal Split Pie Chart from",attr(tripsTable,"table_name")), + description = "generated by plotModalSplitPieChart()", + type = "pie", + width = 1, + props = list(dataset = "modalSplitPieChart.txt", useLastRow = "true") + )) + ) + + if (file.exists(paste0(dump.output.to, dashboard_file))) { + yaml_from_directory <- read_yaml(paste0(dump.output.to, dashboard_file)) + yaml_from_directory$layout <- append(yaml_from_directory$layout, list(new_row = list( + title = paste0("Modal Split Pie Chart from",attr(tripsTable,"table_name")), + description = "generated by plotModalSplitPieChart()", + type = "pie", + width = 1, + props = list(dataset = "modalSplitPieChart.txt", useLastRow = "true") + ))) + names(yaml_from_directory$layout) <- 1:length(names(yaml_from_directory$layout)) + + write_yaml(yaml_from_directory, paste0(dump.output.to, dashboard_file)) + } else { + write_yaml(yaml_list, paste0(dump.output.to, dashboard_file)) + } + if(!only.files){ + return(plt) + } + +} +#' Deprecated function(s) in the matsimr package +#' +#' \strong{plotModalSplitBarChart} - Takes Table trips_output (from \link{read_output_trips}), +#' to plot bar chart with with values that represent +#' percentage of using transport modes from trips +#' +#' @rdname matsimr-deprecated +#' +#' +#' @param tripsTable tible of trips_output (from \link{read_output_trips}) +#' @param 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 +#' @param united.name character string, if columns were united, you can specify name for the resulting column in chart +#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored +#' @param only.files boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly +#' +#' @return \strong{plotModalSplitBarChart} - Bar Chart plot of transport mode distribution, values given in percents +#' +#' @docType package +#' @export plotModalSplitBarChart +#' @aliases plotModalSplitBarChart +#' +plotModalSplitBarChart <- function(tripsTable, + unite.columns = character(0), + united.name = "united", + dump.output.to = matsimDumpOutputDirectory, + only.files = FALSE) { + + .Deprecated("plot_mainmode_barchart") + # If some columns should be united + if (length(unite.columns) != 0) { + tripsTable$main_mode[grep(paste0(unite.columns, collapse = "|"), tripsTable$main_mode)] <- united.name + } + # Get percentage + tripsTableCount <- tripsTable %>% + count(main_mode) %>% + arrange(desc(n)) + text_for_y = tripsTableCount$n + + + fig = plot_ly(data = tripsTableCount,x = ~main_mode,y = ~n,type = "bar", + text = text_for_y, + textposition = "auto", + name = "Distribution of transport type") + fig = fig %>% layout(yaxis = list(title = "Count"),barmode = "group") + + if (file.exists(dump.output.to)) { + #ggsave(paste0(dump.output.to, "/modalSplitBarChart.png"),width = 6,height = 10, fig) + htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/modalSplitBarChart.html")) + } else { + dir.create(dump.output.to) + htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/modalSplitBarChart.html")) + #ggsave(paste0(dump.output.to, "/modalSplitBarChart.png"),width = 6,height = 10, fig) + } + + # Generating yaml and output_files + if (file.exists(dump.output.to)) { + write.table(tripsTableCount,paste0(dump.output.to,"/modalSplitBarChart.csv"),row.names = FALSE,sep = ",") + } else { + dir.create(dump.output.to) + #write_file(paste(tripsTableCount$main_mode, collapse = "\t"), paste0(dump.output.to, "/modalSplitBarChart.txt"), append = FALSE) + #write_file(paste("\r\n", paste(tripsTableCount$n, collapse = "\t")), paste0(dump.output.to, "/modalSplitBarChart.txt"), append = TRUE) + write.table(tripsTableCount,paste0(dump.output.to,"/modalSplitBarChart.csv"),row.names = FALSE,sep = ",") + } + + yaml_list <- list( + header = list(tab = "Summary", title = "Dashboard", description = "Plots from output directory"), + layout = list("1" = list( + title = paste0("Modal Split Bar Chart from ",attr(tripsTable,"table_name")), + description = "generated by plotModalSplitBarChart()", + type = "bar", + width = 1, + props = list(dataset = "modalSplitBarChart.csv", + x = "main_mode", + y = "n", + yAxisTitle = "Count of trips", + xAxisTitle = "Main mode of trip") + )) + ) + + if (file.exists(paste0(dump.output.to, dashboard_file))) { + yaml_from_directory <- read_yaml(paste0(dump.output.to, dashboard_file)) + yaml_from_directory$layout <- append(yaml_from_directory$layout, list(new_row = list( + title = paste0("Modal Split Bar Chart from ",attr(tripsTable,"table_name")), + description = "generated by plotModalSplitBarChart()", + type = "bar", + width = 1, + props = list(dataset = "modalSplitBarChart.csv", + x = "main_mode", + y = "n", + yAxisTitle = "Count of trips", + xAxisTitle = "Main mode of trip") + ))) + names(yaml_from_directory$layout) <- 1:length(names(yaml_from_directory$layout)) + + write_yaml(yaml_from_directory, paste0(dump.output.to, dashboard_file)) + } else { + write_yaml(yaml_list, paste0(dump.output.to, dashboard_file)) + } + # plotting + if(!only.files){ + + fig + return(fig) + } +} + + +#' **Deprecated. (see matsimr-deprecated)** Load MATSIM output_trips table into Memory +#' +#' \strong{readTripsTable} - Loads a MATSim output_trips file from file or archive path, +#' creating a tibble +#' +#' @rdname matsimr-deprecated +#' @name readTripsTable +#' +#' @param input_path character string, path to MATSim output directory or http link to the file. +#' @param n_max integer, maximum number of lines to read within output_trips +#' @return \strong{readTripsTable} - tibble of output_trips +#' +#' @export +readTripsTable <-function(input_path = ".", n_max = Inf) { + .Deprecated("read_output_trips") + return(read_output_trips(input_path,n_max)) +} + +#' Deprecated function(s) in the matsimr package +#' +#' +#' \strong{plotAverageTravelWait} - Takes Table trips_output (from \link{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') +#' +#' +#' +#' @rdname matsimr-deprecated +#' +#' @param tripsTable tible of trips_output (from \link{read_output_trips}) +#' @param 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 +#' @param united.name character string, if columns were united, you can specify name for the resulting column in chart +#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored +#' @param only.files boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly +#' +#' @return \strong{plotAverageTravelWait} - Bar Chart plot of average time spent on travel/wait +#' @docType package +#' @export plotAverageTravelWait +#' @aliases plotAverageTravelWait +#' +plotAverageTravelWait <- function(tripsTable, unite.columns = character(0), united.name = "united",dump.output.to = matsimDumpOutputDirectory, + only.files = FALSE) { + + .Deprecated("plot_travelwaittime_mean_barchart") + # If some columns should be united + if (length(unite.columns) != 0) { + tripsTable$main_mode[grep(paste0(unite.columns, collapse = "|"), tripsTable$main_mode)] <- united.name + } + + avg_time = tripsTable %>% group_by(main_mode)%>% + summarize(trav_time_avg = hms::hms(seconds_to_period(mean(trav_time))), + wait_time_avg = hms::hms(seconds_to_period(mean(wait_time)))) %>% + mutate(trav_time_avg = minute(trav_time_avg),wait_time_avg = minute(wait_time_avg)) + + + fig = plot_ly(data = avg_time,x = ~main_mode,y = ~trav_time_avg,type = 'bar',name = "AVG Time Travelling") + fig = fig %>% add_trace(y = ~wait_time_avg,name = "AVG Time Waiting") + fig = fig %>% layout(yaxis = list(title = "Time spent (in minutes)"),barmode = "group") + + + #plotting + if(!only.files){ + + fig + return(fig) + } + +} + +###Needs to be added, because in master there isn't propper documentation + +#' Deprecated function(s) in the matsimr package +#' +#' +#' @rdname matsimr-deprecated +#' +#' @docType package +#' @export compareAverageTravelWait +#' @aliases compareAverageTravelWait +#' +compareAverageTravelWait <- function(tripsTable1,tripsTable2, unite.columns = character(0), united.name = "united",dump.output.to = matsimDumpOutputDirectory, + only.files = FALSE) { + + .Deprecated("plot_compare_travelwaittime_by_mainmode_barchart") + # If some columns should be united + if (length(unite.columns) != 0) { + tripsTable1$main_mode[grep(paste0(unite.columns, collapse = "|"), tripsTable1$main_mode)] <- united.name + tripsTable2$main_mode[grep(paste0(unite.columns, collapse = "|"), tripsTable2$main_mode)] <- united.name + } + + avg_time1 = tripsTable1 %>% group_by(main_mode)%>% + summarize(trav_time_avg = hms::hms(seconds_to_period(mean(trav_time))), + wait_time_avg = hms::hms(seconds_to_period(mean(wait_time)))) %>% + mutate(trav_time_avg = minute(trav_time_avg),wait_time_avg = minute(wait_time_avg)) %>% arrange(main_mode) + + #print(avg_time1) + + avg_time2 = tripsTable2 %>% group_by(main_mode)%>% + summarize(trav_time_avg = hms::hms(seconds_to_period(mean(trav_time))), + wait_time_avg = hms::hms(seconds_to_period(mean(wait_time)))) %>% + mutate(trav_time_avg = minute(trav_time_avg),wait_time_avg = minute(wait_time_avg)) %>% arrange(main_mode) + + #print(avg_time2) + + avg_time = full_join(avg_time1, avg_time2, by = "main_mode") %>% + replace_na(list(trav_time_avg.x = 0,wait_time_avg.x = 0,trav_time_avg.y = 0,wait_time_avg.y = 0)) + + #print(avg_time) + + avg_time = avg_time %>% mutate(trav_time_avg = trav_time_avg.x - trav_time_avg.y, + wait_time_avg =wait_time_avg.x - wait_time_avg.y )%>% + select(-wait_time_avg.x,-wait_time_avg.y, -trav_time_avg.x,-trav_time_avg.y) + + #print(avg_time) + + fig = plot_ly(data = avg_time,x = ~main_mode,y = ~trav_time_avg,type = 'bar',name = "AVG Time Travelling") + fig = fig %>% add_trace(y = ~wait_time_avg,name = "AVG Time Waiting") + fig = fig %>% layout(yaxis = list(title = "Time spent (in minutes)"),barmode = "group") + + + #plotting + if(!only.files){ + + fig + return(fig) + } + +} + +#' Deprecated function(s) in the matsimr package +#' +#' \strong{plotModalDistanceDistribution} - Takes Table trips_output (from \link{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') +#' +#' +#' @rdname matsimr-deprecated +#' +#' @name plotModalDistanceDistribution +#' +#' @param tripsTable tible of trips_output (from \link{read_output_trips}) +#' @param 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 +#' @param united.name character string, if columns were united, you can specify name for the resulting column in chart +#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored +#' @param only.files boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly +#' +#' @return \strong{plotModalDistanceDistribution} Bar Chart plot of count of trips among distance travelled +#' +#' @export +plotModalDistanceDistribution <- function(tripsTable, unite.columns = character(0), united.name = "united",dump.output.to = matsimDumpOutputDirectory, + only.files = FALSE) { + + .Deprecated("plot_distcat_by_mainmode_barchart") + + # If some columns should be united + if (length(unite.columns) != 0) { + tripsTable$main_mode[grep(paste0(unite.columns, collapse = "|"), tripsTable$main_mode)] <- united.name + } + modes = levels(factor(tripsTable$main_mode)) + + + #To-do: provide array of distance categories + #This is a very bad way to do that, but I see no other way to get it done + #Also filtering table into a new doesn't creates new objects in memory, so it works fast + tripsTable_05km = tripsTable %>% filter(traveled_distance<=1000) %>% mutate(dist_cat = "0-1km") + #tripsTable_1km = tripsTable %>% filter(traveled_distance>500 & traveled_distance<=1000 ) %>% mutate(dist_cat = "0.5-1km") + tripsTable_2km = tripsTable %>% filter(traveled_distance>1000 & traveled_distance<=2000) %>% mutate(dist_cat = "1-2km") + tripsTable_5km = tripsTable %>% filter(traveled_distance>2000 & traveled_distance<=5000) %>% mutate(dist_cat = "2-5km") + tripsTable_10km = tripsTable %>% filter(traveled_distance>5000 & traveled_distance<=10*1000) %>% mutate(dist_cat = "5-10km") + tripsTable_20km = tripsTable %>% filter(traveled_distance>10*1000 & traveled_distance<=20*1000) %>% mutate(dist_cat = "10-20km") + tripsTable_50km = tripsTable %>% filter(traveled_distance>20*1000 & traveled_distance<=50*1000) %>% mutate(dist_cat = "20-50km") + tripsTable_100km = tripsTable %>% filter(traveled_distance>50*1000 & traveled_distance<=100*1000) %>% mutate(dist_cat = "50-100km") + tripsTable_100pluskm = tripsTable %>% filter(traveled_distance>100*1000) %>% mutate(dist_cat = "> 100km") + + tripsTable_result = rbind(tripsTable_05km, + #tripsTable_1km, + tripsTable_2km, + tripsTable_5km, + tripsTable_10km, + tripsTable_20km, + tripsTable_50km, + tripsTable_100km, + tripsTable_100pluskm) + + + tripsTable_result$dist_cat = factor(tripsTable_result$dist_cat,levels = c("0-1km","1-2km","2-5km","5-10km","10-20km","20-50km","50-100km","> 100km")) + + tableWithCounts = tripsTable_result %>% count(main_mode,dist_cat) + + #Reformat the table for simwrapper output + tableToWrite = tripsTable_result %>% select(dist_cat) %>% unique() %>% arrange(dist_cat) + for( mode in modes){ + newColumn = tableWithCounts %>% + filter(main_mode == mode) %>% + mutate(mode = n) %>% + select(dist_cat,mode) + diff = setdiff(tableToWrite$dist_cat,newColumn$dist_cat) + for(dist in diff){ + newColumn = rbind(newColumn,c(dist,0)) + } + newColumn = newColumn %>%arrange(dist_cat) %>% select(-dist_cat) %>% mutate(mode = as.numeric(mode)) + colnames(newColumn)[1] = mode + #print(newColumn) + tableToWrite = cbind(tableToWrite,newColumn) + } + tableToWrite$dist_cat = factor(tableToWrite$dist_cat,ordered = TRUE, + levels = c("0-1km","1-2km","2-5km","5-10km","10-20km","20-50km","50-100km",">100km")) + tableToWrite = tableToWrite %>% arrange(dist_cat) + + + plt = ggplot(tripsTable_result) + + geom_bar(aes(x = dist_cat,fill = main_mode),position = position_dodge())+ + ggtitle("Number of trips per travelling distance") + fig = plotly::ggplotly(plt) + + + if(!only.files){ + + fig + return(fig) + } + +} + +#' Deprecated function(s) in the matsimr package +#' +#' \strong{compareModalDistanceDistribution} - Takes 2 Tables trips_output (from \link{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') +#' +#' @rdname matsimr-deprecated +#' +#' @param tripsTable1 tible of trips_output (from \link{read_output_trips}), number of trips of this table will be extracted from number of trips of tripsTable1 +#' @param tripsTable2 tible of trips_output (from \link{read_output_trips}), from number of trips of this table number of trips of tripsTable1 will be extracted +#' @param 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 +#' @param united.name character string, if columns were united, you can specify name for the resulting column in chart +#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored +#' @param only.files boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly +#' @return \strong{compareModalDistanceDistribution} - Bar Chart plot of count of trips among distance travelled +#' +#' @export +compareModalDistanceDistribution <- function(tripsTable1,tripsTable2, unite.columns = character(0), united.name = "united",dump.output.to = matsimDumpOutputDirectory, + only.files = FALSE) { + + .Deprecated("plot_compare_distcat_by_mainmode_barchart") + + if (length(unite.columns) != 0) { + tripsTable1$main_mode[grep(paste0(unite.columns, collapse = "|"), tripsTable1$main_mode)] <- united.name + tripsTable2$main_mode[grep(paste0(unite.columns, collapse = "|"), tripsTable2$main_mode)] <- united.name + + } + + modes = unique(c(unique(tripsTable1$main_mode),unique(tripsTable2$main_mode))) + distribution1 <- appendDistanceCategory(tripsTable1) + distribution2 <- appendDistanceCategory(tripsTable2) + + tableWithCounts1 = distribution1 %>% count(main_mode,dist_cat) + tableWithCounts2 = distribution2 %>% count(main_mode,dist_cat) + + joined <- full_join(tableWithCounts1, tableWithCounts2, by = c("main_mode", "dist_cat")) + + result <- joined %>% + replace_na( list(n.x = 0, n.y = 0) ) %>% + mutate(n = n.y - n.x) %>% + select(main_mode, dist_cat, n) + + + result$dist_cat = factor(result$dist_cat,levels = c("0-1km","1-2km","2-5km","5-10km","10-20km","20-50km","50-100km","> 100km")) + + tableWithCounts = result + #print(tableWithCounts) + tableToWrite = result %>% select(dist_cat) %>% unique() %>% arrange(dist_cat) + for( mode in modes){ + newColumn = tableWithCounts %>% + filter(main_mode == mode) %>% + mutate(mode = n) %>% + select(dist_cat,mode) + diff = setdiff(tableToWrite$dist_cat,newColumn$dist_cat) + for(dist in diff){ + newColumn = rbind(newColumn,c(dist,0)) + } + newColumn = newColumn %>%arrange(dist_cat) %>% select(-dist_cat) %>% mutate(mode = as.numeric(mode)) + colnames(newColumn)[1] = mode + #print(newColumn) + tableToWrite = cbind(tableToWrite,newColumn) + } + tableToWrite$dist_cat = factor(tableToWrite$dist_cat,ordered = TRUE, + levels = c("0-1km","1-2km","2-5km","5-10km","10-20km","20-50km","50-100km",">100km")) + tableToWrite = tableToWrite %>% arrange(dist_cat) + + + fig = ggplotly(ggplot(result) + + geom_col(aes(x = dist_cat,fill = main_mode, y = n), position = position_dodge())+ + ggtitle("Difference in number of trips per travelling distance")) + + + return(fig) + +} + +#' Deprecated function(s) in the matsimr package +#' +#' \strong{plotTripDistanceByMode} - Takes Table trips_output (from \link{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') +#' +#' @rdname matsimr-deprecated +#' @param tripsTable tible of trips_output (from \link{read_output_trips}) +#' @param 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 +#' @param united.name character string, if columns were united, you can specify name for the resulting column in chart +#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored +#' @param only.files boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly +#' +#' @return \strong{plotTripDistanceByMode} - Bar Chart plot of distance traveled per mode +#' +#' @export +plotTripDistanceByMode <- function(tripsTable, + unite.columns = character(0), united.name = "united", + dump.output.to = matsimDumpOutputDirectory, + only.files = FALSE) { + + .Deprecated("plot_distance_by_mainmode_barchart") + + # If some columns should be united + if (length(unite.columns) != 0) { + tripsTable$main_mode[grep(paste0(unite.columns, collapse = "|"), tripsTable$main_mode)] <- united.name + } + modes = levels(factor(tripsTable$main_mode)) + + table_name = (attr(tripsTable,"table_name")) + tripsTable = tripsTable %>% + group_by(main_mode) %>% + summarize(avg_dist = mean(traveled_distance)/1000) + attr(tripsTable,"table_name") = table_name + + text_for_y = round(tripsTable$avg_dist,digits = 2) + fig = plot_ly(data = tripsTable,x = ~main_mode,y = ~avg_dist, + type = 'bar', + text = text_for_y, + textposition = "auto", + name = "AVG Distance traveled by a person over a day") + fig = fig %>% layout(yaxis = list(title = "Distance (kms)"),barmode = "group") + + if(!only.files){ + + + + fig + return(fig) + } +} + + + +#' Deprecated function(s) in the matsimr package +#' +#' \strong{plotTripCountByDepTime} - Takes Table trips_output (from \link{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') +#' +#' @rdname matsimr-deprecated +#' +#' @param tripsTable tible of trips_output (from \link{read_output_trips}) +#' @param 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 +#' @param united.name character string, if columns were united, you can specify name for the resulting column in chart +#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored +#' @param only.files boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly +#' @return \strong{plotTripCountByDepTime} - Line Chart plot of trips count by departure mode per mode +#' +#' @export +plotTripCountByDepTime <- function(tripsTable, unite.columns = character(0), united.name = "united",dump.output.to = matsimDumpOutputDirectory, + only.files = FALSE) { + + .Deprecated("plot_trips_count_by_deptime_and_mainmode_linechart") + + # If some columns should be united + if (length(unite.columns) != 0) { + tripsTable$main_mode[grep(paste0(unite.columns, collapse = "|"), tripsTable$main_mode)] <- united.name + } + modes = levels(factor(tripsTable$main_mode)) + + + + table_name = (attr(tripsTable,"table_name")) + + tripsTable = tripsTable %>% + mutate(dep_time = hour(dep_time)) %>% + count(dep_time,main_mode) + + attr(tripsTable,"table_name") = table_name #reset table_name + #text_for_y = round(tripsTable$avg_dist,digits = 2) + + + tableToWrite = tripsTable %>% select(dep_time) %>% unique() %>% arrange(dep_time) + for( mode in modes){ + newColumn = tripsTable %>% + filter(main_mode == mode) %>% + mutate(mode = n) %>% + select(dep_time,mode) + for(i in tableToWrite$dep_time){ + if(!i %in% newColumn$dep_time){ + newColumn = rbind(newColumn,c(i,0)) + } + } + #diff = setdiff(tableToWrite$dist_cat,newColumn$dist_cat) + #for(dist in diff){ + #newColumn = rbind(newColumn,c(dist,0)) + #} + newColumn = newColumn %>% arrange(dep_time) %>% select(-dep_time) %>% mutate(mode = as.numeric(mode)) + colnames(newColumn)[1] = mode + #print(newColumn) + tableToWrite = cbind(tableToWrite,newColumn) + } + #print(tableToWrite) + + fig = plot_ly(tripsTable,x = ~dep_time,y = ~n,type = "scatter",mode = "line",linetype = ~main_mode) + fig = fig %>% layout(yaxis = list(title = "Count of trips per departure Time"),barmode = "group") + + #files + + if(!only.files){ + + fig + return(fig) + } +} + +#' Deprecated function(s) in the matsimr package +#' +#' \strong{plotActivityEndTimes} - Takes Table trips_output (from \link{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') +#' +#' @rdname matsimr-deprecated +#' +#' @param tripsTable tible of trips_output (from \link{read_output_trips}) +#' @param unite.columns vector of character strings, that represent patterns of columns to be united, changes name of all activity types in the tibble copy to united_name = "united" that matches PATTERNS given in unite.columns +#' @param united.name character string, if columns were united, you can specify name for the resulting column in chart +#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored +#' @param only.files boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly +#' @return \strong{plotActivityEndTimes} Line plot with departure time x-axis and number start activities on y-axis +#' +#' @export +plotActivityEndTimes <- function(tripsTable, unite.columns = character(0), united.name = "united",dump.output.to = matsimDumpOutputDirectory, + only.files = FALSE) { + + + # If some columns should be united + if (length(unite.columns) != 0) { + tripsTable$start_activity_type[grep(paste0(unite.columns, collapse = "|"), tripsTable$start_activity_type)] <- united.name + } + + + table_name = (attr(tripsTable,"table_name")) + + tripsTable = tripsTable %>% + mutate(dep_time = hour(dep_time),start_activity_type = sapply(strsplit(start_activity_type,"_"),"[[",1)) %>% + count(dep_time,start_activity_type) + + attr(tripsTable,"table_name") = table_name #reset table_name + #text_for_y = round(tripsTable$avg_dist,digits = 2) + + activities = levels(factor(tripsTable$start_activity_type)) + + tableToWrite = tripsTable %>% select(dep_time) %>% unique() %>% arrange(dep_time) + for( act in activities){ + newColumn = tripsTable %>% + filter(start_activity_type == act) %>% + mutate(act = n) %>% + select(dep_time,act) + diff = setdiff(tableToWrite$dep_time,newColumn$dep_time) + for(dtime in diff){ + newColumn = rbind(newColumn,c(dtime,0)) + } + newColumn = newColumn %>%arrange(dep_time) %>% select(-dep_time) %>% mutate(act = as.numeric(act)) + colnames(newColumn)[1] = act + #print(newColumn) + tableToWrite = cbind(tableToWrite,newColumn) + } + + fig = plot_ly(tripsTable,x = ~dep_time,y = ~n,type = "scatter",mode = "line",linetype = ~start_activity_type) + fig = fig %>% layout(yaxis = list(title = "Number of activities ending [n]"), + xaxis = list(title = "Time [h]"), + barmode = "group") + + + #files + #if (file.exists(dump.output.to)) { + # htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/countTripsByDep.html")) + #} else { + # dir.create(dump.output.to) + # htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/countTripsByDep.html")) + # + # } + + # Generating yaml and output_files + + if(!only.files){ + fig + return(fig) + } + +} + +#' Deprecated function(s) in the matsimr package +#' +#' \strong{plotArrivalTimesPerTripPurpose} - Takes Table trips_output (from \link{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') +#' +#' @rdname matsimr-deprecated +#' +#' @param tripsTable tibble of trips_output (from \link{read_output_trips}) +#' @param unite.columns vector of character strings, that represent patterns of columns to be united, changes name of all activity types in the tibble copy to united_name = "united" that matches PATTERNS given in unite.columns +#' @param united.name character string, if columns were united, you can specify name for the resulting column in plot +#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored +#' @param only.files boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly +#' +#' @return \strong{plotArrivalTimesPerTripPurpose} - Line plot with arrival time x-axis and number end activities on y-axis +#' +#' @export +plotArrivalTimesPerTripPurpose <- function(tripsTable, unite.columns = character(0), united.name = "united",dump.output.to = matsimDumpOutputDirectory, + only.files = FALSE) { + + + # If some columns should be united + if (length(unite.columns) != 0) { + tripsTable$end_activity_type[grep(paste0(unite.columns, collapse = "|"), tripsTable$end_activity_type)] <- united.name + } + + + table_name = (attr(tripsTable,"table_name")) + + tripsTable = tripsTable %>% + mutate(arr_time = hour(hms(tripsTable$dep_time)+hms(tripsTable$trav_time))) %>% + mutate(end_activity_type = sapply(strsplit(end_activity_type,"_"),"[[",1)) %>% + count(arr_time,end_activity_type) + + attr(tripsTable,"table_name") = table_name #reset table_name + #text_for_y = round(tripsTable$avg_dist,digits = 2) + + activities = levels(factor(tripsTable$end_activity_type)) + + tableToWrite = tripsTable %>% select(arr_time) %>% unique() %>% arrange(arr_time) + for( act in activities){ + newColumn = tripsTable %>% + filter(end_activity_type == act) %>% + mutate(act = n) %>% + select(arr_time,act) + diff = setdiff(tableToWrite$arr_time,newColumn$arr_time) + for(dtime in diff){ + newColumn = rbind(newColumn,c(dtime,0)) + } + newColumn = newColumn %>%arrange(arr_time) %>% select(-arr_time) %>% mutate(act = as.ncheumeric(act)) + colnames(newColumn)[1] = act + #print(newColumn) + tableToWrite = cbind(tableToWrite,newColumn) + } + + fig = plot_ly(tripsTable,x = ~arr_time,y = ~n,type = "scatter",mode = "line",linetype = ~end_activity_type) + fig = fig %>% layout(yaxis = list(title = "Number of trips ending per trip purpose / Count of activities starting"), + xaxis = list(title = "Time [h]"), + barmode = "group") + + + # #files + # if (file.exists(dump.output.to)) { + # htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/countEndActByArr.html")) + # } else { + # dir.create(dump.output.to) + # htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/countEndActByArr.html")) + # + # } + + # Generating yaml and output_files + if (! file.exists(dump.output.to)) { + dir.create(dump.output.to) + } + write.table(tableToWrite,paste0(dump.output.to,"/countActStartsByTime.csv"),row.names = FALSE,sep = ",") + + yaml_list <- list( + header = list(tab = "Summary", title = "Dashboard", description = "Plots from output directory"), + layout = list("1" = list( + title = paste0("Activity Start Times ",attr(tripsTable,"table_name")), + description = "generated by plotArrivalTimesPerTripPurpose()", + type = "bar", + width = 1, + props = list(dataset = "countActStartsByTime.csv", + x = "arr_time", + y = "[n]", + yAxisTitle = "Number of activities starting / trips ending with purpose", + xAxisTitle = "Time [h]", + stacked = TRUE) + )) + ) + + if (file.exists(paste0(dump.output.to, dashboard_file))) { + yaml_from_directory <- read_yaml(paste0(dump.output.to, dashboard_file)) + yaml_from_directory$layout <- append(yaml_from_directory$layout, list(new_row = list( + title = paste0("Activity Start Times ",attr(tripsTable,"table_name")), + description = "generated by plotArrivalTimesPerTripPurpose()", + type = "bar", + width = 1, + props = list(dataset = "countActStartsByTime.csv", + x = "arr_time", + y = "[n]", + yAxisTitle = "Number of activities starting / trips ending with purpose", + xAxisTitle = "Time [h]", + stacked = TRUE) + ))) + names(yaml_from_directory$layout) <- 1:length(names(yaml_from_directory$layout)) + + write_yaml(yaml_from_directory, paste0(dump.output.to, dashboard_file)) + } else { + write_yaml(yaml_list, paste0(dump.output.to, dashboard_file)) + } + if(!only.files){ + fig + return(fig) + } + +} + + +#' Deprecated function(s) in the matsimr package +#' +#' \strong{plotDepartureTimesPerTripPurpose} - Takes Table trips_output (from \link{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') +#' +#' @rdname matsimr-deprecated +#' +#' @param tripsTable tibble of trips_output (from \link{read_output_trips}) +#' @param unite.columns vector of character strings, that represent patterns of columns to be united, changes name of all activity types in the tibble copy to united_name = "united" that matches PATTERNS given in unite.columns +#' @param united.name character string, if columns were united, you can specify name for the resulting column in plot +#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored +#' @param only.files boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly +#' +#' @return \strong{plotDepartureTimesPerTripPurpose} - Line plot with arrival time x-axis and number end activities on y-axis +#' +#' @export +plotDepartureTimesPerTripPurpose <- function(tripsTable, unite.columns = character(0), united.name = "united", + dump.output.to = matsimDumpOutputDirectory, + only.files = FALSE) { + + + # If some columns should be united + if (length(unite.columns) != 0) { + tripsTable$end_activity_type[grep(paste0(unite.columns, collapse = "|"), tripsTable$end_activity_type)] <- united.name + } + + + table_name = (attr(tripsTable,"table_name")) + + tripsTable = tripsTable %>% + mutate(dep_time = hour(dep_time)) %>% + mutate(end_activity_type = sapply(strsplit(end_activity_type,"_"),"[[",1)) %>% + count(dep_time,end_activity_type) + + attr(tripsTable,"table_name") = table_name #reset table_name + #text_for_y = round(tripsTable$avg_dist,digits = 2) + + activities = levels(factor(tripsTable$end_activity_type)) + + tableToWrite = tripsTable %>% select(dep_time) %>% unique() %>% arrange(dep_time) + for( act in activities){ + newColumn = tripsTable %>% + filter(end_activity_type == act) %>% + mutate(act = n) %>% + select(dep_time,act) + diff = setdiff(tableToWrite$dep_time,newColumn$dep_time) + for(dtime in diff){ + newColumn = rbind(newColumn,c(dtime,0)) + } + newColumn = newColumn %>%arrange(dep_time) %>% select(-dep_time) %>% mutate(act = as.numeric(act)) + colnames(newColumn)[1] = act + #print(newColumn) + tableToWrite = cbind(tableToWrite,newColumn) + } + + fig = plot_ly(tripsTable,x = ~dep_time,y = ~n,type = "scatter",mode = "line",linetype = ~end_activity_type) + fig = fig %>% layout(yaxis = list(title = "Number of trips starting per trip purpose"), + xaxis = list(title = "Time [h]"), + barmode = "group") + + + # #files + + if(!only.files){ + fig + return(fig) + } + +} + + +#' Deprecated function(s) in the matsimr package +#' +#' \strong{plotTripDistancedByType} - Takes Table trips_output (from \link{read_output_trips}), +#' to plot bar chart with with values that represent +#' travelled distance of each tripType related to the shapeTable +#' +#' @rdname matsimr-deprecated +#' +#' @param tripsTable tible of trips_output (from \link{read_output_trips}) +#' @param shapeTable sf object(data.frame with geometries), can be received by using st_read(path_to_geographical_file) +#' @param crs numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation +#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored +#' +#' @return \strong{plotTripDistancedByType} - Bar Chart plot of distance traveled by type +#' +#' @export +plotTripDistancedByType <- function(tripsTable,shapeTable,crs,dump.output.to = matsimDumpOutputDirectory) { + + #Getting all the trip types + filtered_inside = filterByRegion(tripsTable,shapeTable,crs) + filtered_outside = filterByRegion(tripsTable,shapeTable,crs,start.inshape = FALSE,end.inshape = FALSE) + filtered_origin = filterByRegion(tripsTable,shapeTable,crs,start.inshape = TRUE,end.inshape = FALSE) + filtered_destinating = filterByRegion(tripsTable,shapeTable,crs,start.inshape = FALSE,end.inshape = TRUE) + #Adding collumn representing type + filtered_inside = filtered_inside %>% mutate(type = "inside") + filtered_outside = filtered_outside %>% mutate(type = "outside") + filtered_origin = filtered_origin %>% mutate(type = "origin") + filtered_destinating = filtered_origin %>% mutate(type = "destinating") + #Adding all the subtables + result = rbind(filtered_inside,filtered_outside,filtered_destinating,filtered_origin) + #For plotting + travelled = result %>% group_by(type) %>% summarize(travelled = sum(traveled_distance)/1000) + fig = plot_ly(data = travelled,x = ~type,y = ~travelled,type = 'bar',name = "Distance travelled by trip Type") + fig = fig %>% layout(yaxis = list(title = "Distance travelled (in kms)"),barmode = "group") + fig + return(fig) +} + + + +#' Deprecated function(s) in the matsimr package +#' +#' \strong{plotModalShiftSankey} - Takes two trips_table (from \link{read_output_trips}), and collects +#' changes between transport mode distribution of these tables +#' to make alluvial diagram from this data\cr +#' 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 +#' +#' @rdname matsimr-deprecated +#' +#' @param tripsTable1 tible of trips_output (from \link{read_output_trips}) +#' @param tripsTable2 tible of trips_output (from \link{read_output_trips}) +#' @param show.onlyChanges boolean, if it is set to TRUE => sankey diagram only contains changes on axes +#' @param unite.columns vector of character string, changes name of all transport modes in the tibble copy to united_name = "united" that matches PATTERNS given in unite.columns +#' @param united.name if columns were united, you can specify name for the resulting column in plot +#' @param dump.output.to folder that saves and configures yaml for simwrapper. folder where png of plot is stored +#' +#' @return \strong{plotModalShiftSankey} - Alluvial diagram that represents changes in transport mode distribution of trip tables +#' +#' @export +plotModalShiftSankey <- function(tripsTable1, tripsTable2, show.onlyChanges = FALSE, unite.columns = character(0), united.name = "united", dump.output.to = matsimDumpOutputDirectory) { + + .Deprecated("plot_compare_mainmode_sankey") + StatStratum <- ggalluvial::StatStratum + joined <- as_tibble(inner_join(tripsTable1, tripsTable2 %>% + select(trip_id, main_mode), by = "trip_id") %>% + dplyr::rename(base_mode = main_mode.x, policy_mode = main_mode.y)) + + if (show.onlyChanges == TRUE) { + joined <- joined %>% + filter(base_mode != policy_mode) + } + + joined <- joined %>% + group_by(base_mode, policy_mode) %>% + count() + + return(joined) + # If the unite.commercials flag is set to TRUE, then join all commercials under 1 name commercial + if (length(unite.columns) != 0) { + joined$base_mode[grep(paste0(unite.columns, collapse = "|"), joined$base_mode)] <- united.name + joined$policy_mode[grep(paste0(unite.columns, collapse = "|"), joined$policy_mode)] <- united.name + } + # Generating yaml and output_files + if (file.exists(dump.output.to)) { + write.csv2(joined, paste0(dump.output.to, "/modalShift.csv"), row.names = FALSE) + } else { + dir.create(dump.output.to) + write.csv2(joined, paste0(dump.output.to, "/modalShift.csv"), row.names = FALSE) + } + + yaml_list <- list(csv = "/modalShift.csv", title = "Modal Shift Sankey Diagram", description = "generated by plotModalShift") + + write_yaml(yaml_list, paste0(dump.output.to, "/sankey-modalshift.yaml")) + + + + + plt = ggplot(joined, aes(y = n, axis1 = base_mode, axis2 = policy_mode)) + + geom_alluvium(aes(fill = base_mode), width = 1 / 8, knot.pos = 0) + + geom_stratum(width = 1 / 8, alpha = 0.25) + + geom_text(stat = "stratum", aes(label = after_stat(stratum)), size = 3) + + scale_x_discrete(limits = c("Base Mode", "Policy Mode"), expand = c(.05, .05)) + plt + return(plt) +} + +#' Deprecated function(s) in the matsimr package +#' +#' \strong{plotModalShiftBar} - Takes two trips_table (from \link{read_output_trips}), and collects +#' changes between transport mode distribution of these tables +#' to make bar chart diagram with dodging positioning from this data\cr +#' 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 +#' @rdname matsimr-deprecated +#' @param tripsTable1 tible of trips_output (from \link{read_output_trips}) +#' @param tripsTable2 tible of trips_output (from \link{read_output_trips}) +#' @param unite.columns vector of character string, changes name of all transport modes in the tibble copy to united_name = "united" that matches PATTERNS given in unite.columns +#' @param united.name if columns were united, you can specify name for the resulting column in plot +#' @param dump.output.to folder that saves and configures yaml for simwrapper. folder where png of plot is stored +#' +#' @return \strong{plotModalShiftBar} - plots Bar Chart of transport mode changes with additional files for simwrapper +#' +#' @export +plotModalShiftBar <- function(tripsTable1, tripsTable2, unite.columns = character(0), united.name = "united", dump.output.to = matsimDumpOutputDirectory, + output.name = "modalShiftBarChart") { + + .Deprecated("plot_compare_mainmode_barchart") + # If the unite.columns is specified, then + #print(dump.output.to) + if (length(unite.columns) != 0) { + tripsTable1$main_mode[grep(paste0(unite.columns, collapse = "|"), tripsTable1$main_mode)] <- united.name + tripsTable2$main_mode[grep(paste0(unite.columns, collapse = "|"), tripsTable2$main_mode)] <- united.name + } + tripsTable1 = tripsTable1 %>% mutate(type = "base") + tripsTable2 = tripsTable2 %>% mutate(type = "policy") + + total_trips = rbind(tripsTable1,tripsTable2) + + plt = ggplot(total_trips, aes(x =main_mode,fill = factor(type)))+ + geom_bar(position = position_dodge())+ + coord_flip() + plotly::ggplotly(plt) + + return(plotly::ggplotly(plt)) +} + + + +#' Deprecated function(s) in the matsimr package +#' +#' \strong{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:\cr +#' if start.inshape = TRUE & end.inshape = TRUE return table that contains trips inside given shape +#' \cr if start.inshape = TRUE & end.inshape = FALSE return table that contains trips which starts in shape and ends out of the shape +#' \cr if start.inshape = FALSE & end.inshape = TRUE return table that contains trips which ends in shape and starts out of the shape +#' \cr if start.inshape = FALSE & end.inshape = FALSE return table that contains trips which starts and ends our of the given shape +#' \cr result of filtering is plotted on map of shapeTable where green points are startpoints of trip and red points are endpoints of trip +#' +#' @rdname matsimr-deprecated +#' @param table tibble of trips_output (from \link{read_output_trips}) +#' +#' @param shapeTable sf object(data.frame with geometries), can be received by using st_read(path_to_geographical_file) +#' +#' @param crs numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation +#' +#' @param start.inshape bool, defines trips to conclude (see Description) +#' +#' @param end.inshape bool, defines trips to conclude (see Description) +#' +#' @param optimized bool, by default FALSE and gives interactive plot using leaflet, if TRUE using image with ggplot +#' +#' +#' @return \strong{plotMapWithFilteredTrips} - plot with trips filtered depending on flags *.inshape on map from shapeTable +#' +#' @export +plotMapWithFilteredTrips <- function(table, shapeTable, crs, start.inshape = TRUE, end.inshape = TRUE, optimized = FALSE) { + # table = table[1:5000,] #To make plotting faster + # table_sf = transformToSf(table,crs = crs) + filtered <- filterByRegion(table, shapeTable, crs = crs, start.inshape, end.inshape) + if (nrow(filtered) == 0) { + ggplot() + + geom_sf(data = shapeTable) + warning("there is no trip filtered for this map") + return(NaN) + } + filtered_sf <- transformToSf(filtered, crs = crs, geometry.type = st_point()) + st_geometry(filtered_sf) <- "start_wkt" + filtered_sf_start <- filtered_sf %>% select(-end_wkt) + st_geometry(filtered_sf) <- "end_wkt" + filtered_sf_end <- filtered_sf %>% select(-start_wkt) + # shape = st_read(shapePath) + if (st_crs(shapeTable) == NA) { + ct_crs(shapeTable) <- crs + } + shapeTable <- st_transform(shapeTable, crs = "+proj=longlat +datum=WGS84 +no_defs") + filtered_sf_start <- st_transform(filtered_sf_start, "+proj=longlat +datum=WGS84 +no_defs") + filtered_sf_end <- st_transform(filtered_sf_end, "+proj=longlat +datum=WGS84 +no_defs") + + if (optimized) { + colors <- c("Start" = "blue", "End" = "red") + shapes <- c("Start" = 5, "End" = 3) + # ggplot2 isn't interactive! + plt <- ggplot() + + geom_sf(data = shapeTable) + + # geom_sf(data = ) + geom_sf(data = filtered_sf_start, aes(color = "Start"), size = 1, shape = 5) + + geom_sf(data = filtered_sf_end, aes(color = "End"), size = 1, shape = 3) + + labs(color = "Type") + + scale_colour_manual(values = colors) + plt + return(plt) + } + + + + + + # If we need to change design + # css_fix <- "div.info.legend.leaflet-control br {clear: both;}" + # Convert CSS to HTML + # html_fix <- htmltools::tags$style(type = "text/css", css_fix) + + + plt <- leaflet() %>% + addTiles() %>% + addProviderTiles( + "OpenStreetMap", + # give the layer a name + group = "OpenStreetMap" + ) %>% + addProviderTiles( + "Stamen.Toner", + group = "Stamen.Toner" + ) %>% + addProviderTiles( + "Stamen.Terrain", + group = "Stamen.Terrain" + ) %>% + addProviderTiles( + "Esri.WorldStreetMap", + group = "Esri.WorldStreetMap" + ) %>% + addProviderTiles( + "Wikimedia", + group = "Wikimedia" + ) %>% + addProviderTiles( + "CartoDB.Positron", + group = "CartoDB.Positron" + ) %>% + addProviderTiles( + "Esri.WorldImagery", + group = "Esri.WorldImagery" + ) %>% + addPolygons(data = shapeTable, opacity = 0.1, color = "green") %>% + addCircleMarkers(filtered_sf_start, + lng = st_coordinates(filtered_sf_start$start_wkt)[, 1], + lat = st_coordinates(filtered_sf_start$start_wkt)[, 2], radius = 3, color = "blue", + label = paste( + "Person_id:", + filtered_sf_start$person, "
", + "Trip_id:", + filtered_sf_start$trip_id, "
", + "main_mode:", filtered_sf_start$main_mode, "
", + "type:", "start", "
", + "Start activity:", + filtered_sf_start$start_activity_type, "
" + ) %>% lapply(htmltools::HTML) + ) %>% + addCircleMarkers(filtered_sf_end, + lng = st_coordinates(filtered_sf_end$end_wkt)[, 1], + lat = st_coordinates(filtered_sf_end$end_wkt)[, 2], radius = 0.15, color = "red", + label = paste( + "Person_id:", + filtered_sf_end$person, "
", + "Trip_id:", + filtered_sf_end$trip_id, "
", + "main_mode:", filtered_sf_end$main_mode, "
", + "type:", "end", "
", + "End activity:", + filtered_sf_end$end_activity_type, "
" + ) %>% lapply(htmltools::HTML) + ) %>% + addLegend( + colors = c("blue", "red"), + labels = c("Start of trip", "End of trip"), + position = "bottomleft", + title = "Type of the point", + opacity = 0.9 + ) %>% + addMiniMap() %>% + addLayersControl( + baseGroups = c( + "OpenStreetMap", "Stamen.Toner", + "Stamen.Terrain", "Esri.WorldStreetMap", + "Wikimedia", "CartoDB.Positron", "Esri.WorldImagery" + ), + # position it on the topleft + position = "topleft" + ) + + return(plt) +} + + +#' Deprecated function(s) in the matsimr package +#' +#' \strong{plotMapWithTrips} - Plots start and end coordinates of the given trips table on an osm map +#' @rdname matsimr-deprecated +#' @param table tibble of trips_output (from \link{read_output_trips}) +#' +#' +#' @param crs numeric representation of the EPSG code or proj4string for the corresponding coordinate system of the trip coordinates, can be found in network file from output directory of MATSim simulation +#' +#' @param optimized bool, by default FALSE and gives interactive plot using leaflet, if TRUE using image with ggplot +#' +#' +#' @return \strong{plotMapWithTrips} - plot with trips +#' +#' @export +plotMapWithTrips <- function(table, crs, optimized = FALSE) { + + table_sf <- transformToSf(table, crs = crs, geometry.type = st_point()) + st_geometry(table_sf) <- "start_wkt" + table_sf_start <- table_sf %>% select(-end_wkt) + st_geometry(table_sf) <- "end_wkt" + table_sf_end <- table_sf %>% select(-start_wkt) + + table_sf_start <- st_transform(table_sf_start, "+proj=longlat +datum=WGS84 +no_defs") + table_sf_end <- st_transform(table_sf_end, "+proj=longlat +datum=WGS84 +no_defs") + + if (optimized) { + colors <- c("Start" = "blue", "End" = "red") + shapes <- c("Start" = 5, "End" = 3) + # ggplot2 isn't interactive! + plt <- ggplot() + + geom_sf(data = table_sf_start, aes(color = "Start"), size = 1, shape = 5) + + geom_sf(data = table_sf_end, aes(color = "End"), size = 1, shape = 3) + + labs(color = "Type") + + scale_colour_manual(values = colors) + plt + return(plt) + } + + + + + + # If we need to change design + # css_fix <- "div.info.legend.leaflet-control br {clear: both;}" + # Convert CSS to HTML + # html_fix <- htmltools::tags$style(type = "text/css", css_fix) + + + plt <- leaflet() %>% + addTiles() %>% + addProviderTiles( + "OpenStreetMap", + # give the layer a name + group = "OpenStreetMap" + ) %>% + addProviderTiles( + "Stamen.Toner", + group = "Stamen.Toner" + ) %>% + addProviderTiles( + "Stamen.Terrain", + group = "Stamen.Terrain" + ) %>% + addProviderTiles( + "Esri.WorldStreetMap", + group = "Esri.WorldStreetMap" + ) %>% + addProviderTiles( + "Wikimedia", + group = "Wikimedia" + ) %>% + addProviderTiles( + "CartoDB.Positron", + group = "CartoDB.Positron" + ) %>% + addProviderTiles( + "Esri.WorldImagery", + group = "Esri.WorldImagery" + ) %>% + addCircleMarkers(table_sf_start, + lng = st_coordinates(table_sf_start$start_wkt)[, 1], + lat = st_coordinates(table_sf_start$start_wkt)[, 2], radius = 3, color = "blue", + label = paste( + "Person_id:", + table_sf_start$person, "
", + "Trip_id:", + table_sf_start$trip_id, "
", + "main_mode:", table_sf_start$main_mode, "
", + "type:", "start", "
", + "Start activity:", + table_sf_start$start_activity_type, "
" + ) %>% lapply(htmltools::HTML) + ) %>% + addCircleMarkers(table_sf_end, + lng = st_coordinates(table_sf_end$end_wkt)[, 1], + lat = st_coordinates(table_sf_end$end_wkt)[, 2], radius = 0.15, color = "red", + label = paste( + "Person_id:", + table_sf_end$person, "
", + "Trip_id:", + table_sf_end$trip_id, "
", + "main_mode:", table_sf_end$main_mode, "
", + "type:", "end", "
", + "End activity:", + table_sf_end$end_activity_type, "
" + ) %>% lapply(htmltools::HTML) + ) %>% + addLegend( + colors = c("blue", "red"), + labels = c("Start of trip", "End of trip"), + position = "bottomleft", + title = "Type of the point", + opacity = 0.9 + ) %>% + addMiniMap() %>% + addLayersControl( + baseGroups = c( + "OpenStreetMap", "Stamen.Toner", + "Stamen.Terrain", "Esri.WorldStreetMap", + "Wikimedia", "CartoDB.Positron", "Esri.WorldImagery" + ), + # position it on the topleft + position = "topleft" + ) + plt + return(plt) +} + +#' Deprecated function(s) in the matsimr package +#' +#' \strong{plotTripTypesPieChart} - plots distribution of every type of trips(inside, outside, origin and destinating) in Pie Chart +#' +#' @rdname matsimr-deprecated +#' +#' @param table tibble of trips_output (from \link{read_output_trips}) +#' +#' @param shapeTable sf object(data.frame with geometries), can be received by using st_read(path_to_geographical_file) +#' +#' @param crs numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation +#' +#' +#' +#' @return \strong{plotTripTypesPieChart} - plot with percentage of each type of trips +#' +#' @export +plotTripTypesPieChart <- function(table, shapeTable, crs) { + + .Deprecated("") + # table_sf = transformToSf(table,crs = crs) + # Maybe union all this tables as 1 extended with additional column + filtered_inside <- filterByRegion(table, shapeTable, crs = crs, start.inshape = TRUE, end.inshape = TRUE) + filtered_origin <- filterByRegion(table, shapeTable, crs = crs, start.inshape = TRUE, end.inshape = FALSE) + filtered_destination <- filterByRegion(table, shapeTable, crs = crs, start.inshape = FALSE, end.inshape = TRUE) + filtered_transit <- filterByRegion(table, shapeTable, crs = crs, start.inshape = FALSE, end.inshape = FALSE) + + result <- tibble( + n = c(nrow(filtered_inside), nrow(filtered_transit), nrow(filtered_origin), nrow(filtered_destination)), + type = c("inside the shape", "outside the shape", "starting in shape", "ending in shape") + ) + + # result gives percentage representation out + result <- result %>% mutate(n = n / sum(n) * 100) + + # getthe positions + positions <- result %>% + mutate( + csum = rev(cumsum(rev(n))), + pos = n / 2 + lead(csum, 1), + pos = if_else(is.na(pos), n / 2, pos) + ) + + return(ggplot(result, aes(x = "", y = n, fill = fct_inorder(type))) + + geom_col(width = 1, col = 1) + + geom_bar(stat = "identity", width = 1) + + coord_polar("y") + + # geom_text(aes(label = round(n,digits = 1)), + # position=position_stack(vjust = 0.5), + # show.legend = FALSE,size = 4)+ + geom_label_repel( + data = positions, + aes(y = pos, label = paste0(round(n, digits = 1), "%")), + size = 4.5, nudge_x = 1, show.legend = FALSE + ) + + ggtitle("Distribution")) +} + + +#' Deprecated function(s) in the matsimr package +#' +#' \strong{compareTripTypesBarChart} - Creates BarChart of changing trip types(originating,transit etc) between 2 tables +#' and saves output to dump.output.to +#' +#' @rdname matsimr-deprecated +#' +#' @param tripsTable1 tibble of trips_output (from \link{read_output_trips},f.e. base case) +#' +#' @param tripsTable2 tibble of trips_output (from \link{read_output_trips},f.e. policy case) +#' +#' @param shapeTable sf object(data.frame with geometries), can be received by using st_read(path_to_geographical_file) +#' +#' @param crs numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation +#' +#' @param dump.output.to folder that saves resulting image of BarChart +#' +#' +#' @return \strong{compareTripTypesBarChart} - plot with percentage of each type of trips between 2 tables +#' +#' @export +compareTripTypesBarChart <- function(tripsTable1,tripsTable2,shapeTable,crs,dump.output.to = matsimDumpOutputDirectory){ + # table_sf = transformToSf(table,crs = crs) + # Maybe union all this tables as 1 extended with additional column + filtered_inside1 <- filterByRegion(tripsTable1, shapeTable, crs = crs, start.inshape = TRUE, end.inshape = TRUE) %>% + mutate(type = "inside",table_num = "1 table") + filtered_origin1 <- filterByRegion(tripsTable1, shapeTable, crs = crs, start.inshape = TRUE, end.inshape = FALSE) %>% + mutate(type = "start_in_shape",table_num = "1 table") + filtered_destination1 <- filterByRegion(tripsTable1, shapeTable, crs = crs, start.inshape = FALSE, end.inshape = TRUE) %>% + mutate(type = "endind_in_shape",table_num = "1 table") + filtered_transit1 <- filterByRegion(tripsTable1, shapeTable, crs = crs, start.inshape = FALSE, end.inshape = FALSE)%>% + mutate(type = "outside",table_num = "1 table") + + filtered_inside2 <- filterByRegion(tripsTable2, shapeTable, crs = crs, start.inshape = TRUE, end.inshape = TRUE) %>% + mutate(type = "inside",table_num = "2 table") + filtered_origin2 <- filterByRegion(tripsTable2, shapeTable, crs = crs, start.inshape = TRUE, end.inshape = FALSE) %>% + mutate(type = "start_in_shape",table_num = "2 table") + filtered_destination2 <- filterByRegion(tripsTable2, shapeTable, crs = crs, start.inshape = FALSE, end.inshape = TRUE) %>% + mutate(type = "endind_in_shape",table_num = "2 table") + filtered_transit2 <- filterByRegion(tripsTable2, shapeTable, crs = crs, start.inshape = FALSE, end.inshape = FALSE)%>% + mutate(type = "outside",table_num = "2 table") + + + result_table = rbind(filtered_inside1,filtered_origin1,filtered_destination1,filtered_transit1, + filtered_inside2,filtered_origin2,filtered_destination2,filtered_transit2) + + plt = ggplot(result_table, aes(x =type,fill = factor(table_num)))+ + geom_bar(position = position_dodge())+ + coord_flip() + plotly::ggplotly(plt) + + if (file.exists(dump.output.to)) { + ggsave(paste0(dump.output.to, "/tripTypeComparison.png"), plot = plt,width = 6,height = 10) + } else { + dir.create(dump.output.to) + ggsave(paste0(dump.output.to, "/tripTypeComparison.png"), plot = plt,width = 6,height = 10) + } + + return(plotly::ggplotly(plt)) + +} + + +#' Deprecated function(s) in the matsimr package +#' +#' \strong{plotMapWithTripsType} - plots every type of trips(inside, outside, origin and destinating) on map +#' +#' @rdname matsimr-deprecated +#' +#' @param table tibble of trips_output (from \link{read_output_trips}) +#' +#' @param shapeTable sf object(data.frame with geometries), can be received by using st_read(path_to_geographical_file) +#' +#' @param crs numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation +#' +#' @param optimized bool, by default FALSE and gives interactive plot using leaflet, if TRUE using image with ggplot +#' +#' @return \strong{plotMapWithTripsType} - plot that contains every trip with defined trip type +#' +#' @export +plotMapWithTripsType <- function(table, shapeTable, crs, optimized = FALSE) { + # table = table[1:5000,] #To make plotting faster + # table_sf = transformToSf(table,crs = crs) + # Maybe union all this tables as 1 extended with additional column + filtered_inside <- filterByRegion(table, shapeTable, crs = crs, start.inshape = TRUE, end.inshape = TRUE) + filtered_origin <- filterByRegion(table, shapeTable, crs = crs, start.inshape = TRUE, end.inshape = FALSE) + filtered_destination <- filterByRegion(table, shapeTable, crs = crs, start.inshape = FALSE, end.inshape = TRUE) + filtered_transit <- filterByRegion(table, shapeTable, crs = crs, start.inshape = FALSE, end.inshape = FALSE) + + filtered_sf_inside <- transformToSf(filtered_inside, crs = crs, geometry.type = st_multipoint()) + filtered_sf_origin <- transformToSf(filtered_origin, crs = crs, geometry.type = st_multipoint()) + filtered_sf_destination <- transformToSf(filtered_destination, crs = crs, geometry.type = st_multipoint()) + filtered_sf_transit <- transformToSf(filtered_transit, crs = crs, geometry.type = st_multipoint()) + + if (st_crs(shapeTable) == NA) { + ct_crs(shapeTable) <- crs + } + + shapeTable <- st_transform(shapeTable, crs = "+proj=longlat +datum=WGS84 +no_defs") + filtered_sf_inside <- st_transform(filtered_sf_inside, "+proj=longlat +datum=WGS84 +no_defs") + filtered_sf_origin <- st_transform(filtered_sf_origin, "+proj=longlat +datum=WGS84 +no_defs") + filtered_sf_destination <- st_transform(filtered_sf_destination, "+proj=longlat +datum=WGS84 +no_defs") + filtered_sf_transit <- st_transform(filtered_sf_transit, "+proj=longlat +datum=WGS84 +no_defs") + + if (optimized) { + colors <- c("inside" = "green", "origin" = "red", "destination" = "orange", "transit" = "blue") + shapes <- c("Start" = 5, "End" = 3) + plt <- ggplot() + + geom_sf(data = shapeTable) + + # geom_sf(data = ) + geom_sf(data = filtered_sf_inside, aes(color = "inside"), size = 3, alpha = 0.5) + + geom_sf(data = filtered_sf_origin, aes(color = "origin"), size = 3, alpha = 0.4) + + geom_sf(data = filtered_sf_destination, aes(color = "destination"), size = 3, alpha = 0.3) + + geom_sf(data = filtered_sf_transit, aes(color = "transit"), size = 2, alpha = 0.1) + + labs(color = "Type") + + scale_colour_manual(values = colors) + plt + return((plt)) + } + + # If we need to adjust design + # css_fix <- "div.info.legend.leaflet-control br {clear: both;}" + # Convert CSS to HTML + # html_fix <- htmltools::tags$style(type = "text/css", css_fix) + + + plt <- leaflet() %>% + addTiles() %>% + addProviderTiles( + "OpenStreetMap", + # give the layer a name + group = "OpenStreetMap" + ) %>% + addProviderTiles( + "Stamen.Toner", + group = "Stamen.Toner" + ) %>% + addProviderTiles( + "Stamen.Terrain", + group = "Stamen.Terrain" + ) %>% + addProviderTiles( + "Esri.WorldStreetMap", + group = "Esri.WorldStreetMap" + ) %>% + addProviderTiles( + "Wikimedia", + group = "Wikimedia" + ) %>% + addProviderTiles( + "CartoDB.Positron", + group = "CartoDB.Positron" + ) %>% + addProviderTiles( + "Esri.WorldImagery", + group = "Esri.WorldImagery" + ) %>% + addPolygons(data = shapeTable, opacity = 0.1, color = "green") %>% + addCircleMarkers(filtered_sf_inside, + lng = st_coordinates(filtered_sf_inside$wkt)[seq(1, length(filtered_sf_inside$wkt), 2), 1], + lat = st_coordinates(filtered_sf_inside$wkt)[seq(1, length(filtered_sf_inside$wkt), 2), 2], radius = 3, color = "blue", + label = paste( + "Person_id:", + filtered_sf_inside$person, "
", + "Trip_id:", + filtered_sf_inside$trip_id, "
", + "main_mode:", filtered_sf_inside$main_mode, "
", + "type:", "start", "
", + "Start activity:", + filtered_sf_inside$start_activity_type, "
" + ) %>% lapply(htmltools::HTML) + ) %>% + addCircleMarkers(filtered_sf_inside, + lng = st_coordinates(filtered_sf_inside$wkt)[seq(2, length(filtered_sf_inside$wkt), 2), 1], + lat = st_coordinates(filtered_sf_inside$wkt)[seq(2, length(filtered_sf_inside$wkt), 2), 2], radius = 3, color = "blue", + label = paste( + "Person_id:", + filtered_sf_inside$person, "
", + "Trip_id:", + filtered_sf_inside$trip_id, "
", + "main_mode:", filtered_sf_inside$main_mode, "
", + "type:", "end", "
", + "End activity:", + filtered_sf_inside$end_activity_type, "
" + ) %>% lapply(htmltools::HTML) + ) %>% + addCircleMarkers(filtered_sf_origin, + lng = st_coordinates(filtered_sf_origin$wkt)[seq(1, length(filtered_sf_inside$wkt), 2), 1], + lat = st_coordinates(filtered_sf_origin$wkt)[seq(1, length(filtered_sf_inside$wkt), 2), 2], radius = 2, color = "red", + label = paste( + "Person_id:", + filtered_sf_origin$person, "
", + "Trip_id:", + filtered_sf_origin$trip_id, "
", + "main_mode:", filtered_sf_origin$main_mode, "
", + "type:", "start", "
", + "Start activity:", + filtered_sf_origin$end_activity_type, "
" + ) %>% lapply(htmltools::HTML) + ) %>% + addCircleMarkers(filtered_sf_origin, + lng = st_coordinates(filtered_sf_origin$wkt)[seq(2, length(filtered_sf_inside$wkt), 2), 1], + lat = st_coordinates(filtered_sf_origin$wkt)[seq(2, length(filtered_sf_inside$wkt), 2), 2], radius = 2, color = "red", + label = paste( + "Person_id:", + filtered_sf_origin$person, "
", + "Trip_id:", + filtered_sf_origin$trip_id, "
", + "main_mode:", filtered_sf_origin$main_mode, "
", + "type:", "end", "
", + "End activity:", + filtered_sf_origin$end_activity_type, "
" + ) %>% lapply(htmltools::HTML) + ) %>% + addCircleMarkers(filtered_sf_destination, + lng = st_coordinates(filtered_sf_destination$wkt)[seq(1, length(filtered_sf_inside$wkt), 2), 1], + lat = st_coordinates(filtered_sf_destination$wkt)[seq(1, length(filtered_sf_inside$wkt), 2), 2], radius = 1, color = "orange", + label = paste( + "Person_id:", + filtered_sf_destination$person, "
", + "Trip_id:", + filtered_sf_destination$trip_id, "
", + "main_mode:", filtered_sf_destination$main_mode, "
", + "type:", "start", "
", + "Start activity:", + filtered_sf_destination$end_activity_type, "
" + ) %>% lapply(htmltools::HTML) + ) %>% + addCircleMarkers(filtered_sf_destination, + lng = st_coordinates(filtered_sf_destination$wkt)[seq(2, length(filtered_sf_inside$wkt), 2), 1], + lat = st_coordinates(filtered_sf_destination$wkt)[seq(2, length(filtered_sf_inside$wkt), 2), 2], radius = 1, color = "orange", + label = paste( + "Person_id:", + filtered_sf_destination$person, "
", + "Trip_id:", + filtered_sf_destination$trip_id, "
", + "main_mode:", filtered_sf_destination$main_mode, "
", + "type:", "end", "
", + "End activity:", + filtered_sf_destination$end_activity_type, "
" + ) %>% lapply(htmltools::HTML) + ) %>% + addCircleMarkers(filtered_sf_transit, + lng = st_coordinates(filtered_sf_transit$wkt)[seq(1, length(filtered_sf_inside$wkt), 2), 1], + lat = st_coordinates(filtered_sf_transit$wkt)[seq(1, length(filtered_sf_inside$wkt), 2), 2], radius = 0.15, color = "black", + label = paste( + "Person_id:", + filtered_sf_transit$person, "
", + "Trip_id:", + filtered_sf_transit$trip_id, "
", + "main_mode:", filtered_sf_transit$main_mode, "
", + "type:", "start", "
", + "Start activity:", + filtered_sf_transit$end_activity_type, "
" + ) %>% lapply(htmltools::HTML) + ) %>% + addCircleMarkers(filtered_sf_transit, + lng = st_coordinates(filtered_sf_transit$wkt)[seq(2, length(filtered_sf_inside$wkt), 2), 1], + lat = st_coordinates(filtered_sf_transit$wkt)[seq(2, length(filtered_sf_inside$wkt), 2), 2], radius = 0.15, color = "black", + label = paste( + "Person_id:", + filtered_sf_transit$person, "
", + "Trip_id:", + filtered_sf_transit$trip_id, "
", + "main_mode:", filtered_sf_transit$main_mode, "
", + "type:", "end", "
", + "End activity:", + filtered_sf_transit$end_activity_type, "
" + ) %>% lapply(htmltools::HTML) + ) %>% + addLegend( + colors = c("blue", "red", "orange", "black"), + labels = c( + "Trips inside of region", + "Trips with the end outside region", + "Trips with the start outside region", + "Trips that start and end outside region" + ), + position = "bottomleft", + title = "Type of the point", + opacity = 0.9 + ) %>% + addMiniMap() %>% + addLayersControl( + baseGroups = c( + "OpenStreetMap", "Stamen.Toner", + "Stamen.Terrain", "Esri.WorldStreetMap", + "Wikimedia", "CartoDB.Positron", "Esri.WorldImagery" + ), + # position it on the topleft + position = "topleft" + ) + + return(plt) +} + + +#' Deprecated function(s) in the matsimr package +#' +#' \strong{compareBasePolicyOutput} - Chooses a function to compare output_trips from the folders. +#' baseFolder contains all base outputs, policyFolder contains all policy outputs. +#' +#' @rdname matsimr-deprecated +#' +#' @param baseFolder specifies data source folder with multiple base output_trips +#' +#' @param policyFolder specifies data source folder with multiple policy output_trips +#' +#' @param dump.output.to that saves result of all comparisons between each base and each policy. +#' For now it creates plotModalShiftBar() for the output_trips +#' +#' @return \strong{compareBasePolicyOutput} - list of tibbles, list of all base and policy output_trips as tibble +#' +#' @export +compareBasePolicyOutput <- function(baseFolder,policyFolder,dump.output.to = matsimDumpOutputDirectory) { + + base_trips = list(NULL) + policy_trips = list(NULL) + for(file in list.files(baseFolder,full.names = TRUE)) + { + temp = readTripsTable(file) + if(!is.null(temp)){ + attr(temp,"table_name") = strsplit(file,'/')[[1]][-1] + if(is.null(base_trips[[1]])){ + base_trips[[1]] = temp + }else{ + base_trips = append(base_trips,list(temp)) + } + } + } + + for(file in list.files(policyFolder,full.names = TRUE)) + { + temp = readTripsTable(file) + if(!is.null(temp)){ + attr(temp,"table_name") = strsplit(file,'/')[[1]][-1] + if(is.null(policy_trips[[1]])){ + policy_trips[[1]] = temp + }else{ + policy_trips = append(policy_trips,list(temp)) + } + } + } + i = 0; + + print(dump.output.to) + if (!file.exists(dump.output.to)) { + dir.create(dump.output.to) + } + for(base in base_trips){ + + for(policy in policy_trips){ + print(paste0(i," comparison")) + name = paste0(i,"_",attr(base,"table_name"),"--",attr(policy,"table_name")) + plotModalShiftBar(base, + policy, + dump.output.to = dump.output.to, + output.name = name) + + i=i+1 + } + } + invisible(list(base = base_trips,policy = policy_trips)) +} + +#' Deprecated function(s) in the matsimr package +#' +#' \strong{compareBasePolicyShapeOutput} - Chooses a function to compare output_trips from the folders. +#' baseFolder contains all base outputs, policyFolder contains all policy outputs. +#' +#' @rdname matsimr-deprecated +#' +#' @param baseFolder specifies data source folder with multiple base output_trips +#' +#' @param policyFolder specifies data source folder with multiple policy output_trips +#' +#' @param shapeFilePath specifies shapeFile used for comparison +#' @param crs numeric of EPSG code or proj4string, can be found in network/config file from output directory of MATSim simulation +#' @param dump.output.to that saves result of all comparisons between each base and each policy. +#' For now it creates plotModalShiftBar() for the output_trips +#' +#' @return \strong{compareBasePolicyShapeOutput} - list of tibbles, list of all base and policy output_trips as tibble +#' +#' @export +compareBasePolicyShapeOutput <- function(baseFolder,policyFolder,shapeFilePath,crs,dump.output.to = matsimDumpOutputDirectory) { + + + base_trips = list(NULL) + policy_trips = list(NULL) + shape = st_read(shapeFilePath) + for(file in list.files(baseFolder,full.names = TRUE)) + { + temp = readTripsTable(file) + if(!is.null(temp)){ + attr(temp,"table_name") = strsplit(file,'/')[[1]][-1] + if(is.null(base_trips[[1]])){ + base_trips[[1]] = temp + }else{ + base_trips = append(base_trips,list(temp)) + } + } + } + + for(file in list.files(policyFolder,full.names = TRUE)) + { + temp = readTripsTable(file) + if(!is.null(temp)){ + attr(temp,"table_name") = strsplit(file,'/')[[1]][-1] + if(is.null(policy_trips[[1]])){ + policy_trips[[1]] = temp + }else{ + policy_trips = append(policy_trips,list(temp)) + } + } + } + i = 0; + + if (!file.exists(dump.output.to)) { + dir.create(dump.output.to) + } + for(base in base_trips){ + + for(policy in policy_trips){ + print(paste0(i," comparison")) + plotModalShiftBar(base, + policy, + crs, + dump.output.to = paste0(dump.output.to,"/",i,"_",attr(base,"table_name"),"--",attr(policy,"table_name")) ) + compareTripTypesBarChart(base,policy,shape,crs,dump.output.to = paste0(dump.output.to,"/",i,"_",attr(base,"table_name"),"--",attr(policy,"table_name"))) + i=i+1 + + } + } + invisible(list(base = base_trips,policy = policy_trips)) +} + + +#' Deprecated function(s) in the matsimr package +#' +#' \strong{appendDistanceCategory} - adds to trips output tibble additional column that represent distance as category +#' +#' @rdname matsimr-deprecated +#' +#' @return tibble of output_trips with distance category column +#' +#' @docType package +#' +#' @export +appendDistanceCategory <- function(tripsTable){ + + .Deprecated("process_append_distcat") + modes = levels(factor(tripsTable$main_mode)) + + #This is a very bad way to do that, but I see no other way to get it done + #Also filtering table into a new doesn't creates new objects in memory, so it works fast + #Upd: it creates copy of dataframe on each mutate :/ + + + tripsTable_05km = tripsTable %>% filter(traveled_distance<=1000) %>% mutate(dist_cat = "0-1km") + tripsTable_2km = tripsTable %>% filter(traveled_distance>1000 & traveled_distance<=2000) %>% mutate(dist_cat = "1-2km") + tripsTable_5km = tripsTable %>% filter(traveled_distance>2000 & traveled_distance<=5000) %>% mutate(dist_cat = "2-5km") + tripsTable_10km = tripsTable %>% filter(traveled_distance>5000 & traveled_distance<=10*1000) %>% mutate(dist_cat = "5-10km") + tripsTable_20km = tripsTable %>% filter(traveled_distance>10*1000 & traveled_distance<=20*1000) %>% mutate(dist_cat = "10-20km") + tripsTable_50km = tripsTable %>% filter(traveled_distance>20*1000 & traveled_distance<=50*1000) %>% mutate(dist_cat = "20-50km") + tripsTable_100km = tripsTable %>% filter(traveled_distance>50*1000 & traveled_distance<=100*1000) %>% mutate(dist_cat = "50-100km") + tripsTable_100pluskm = tripsTable %>% filter(traveled_distance>100*1000) %>% mutate(dist_cat = "> 100km") + + tripsTable_result = rbind(tripsTable_05km, + #tripsTable_1km, + tripsTable_2km, + tripsTable_5km, + tripsTable_10km, + tripsTable_20km, + tripsTable_50km, + tripsTable_100km, + tripsTable_100pluskm) + + tripsTable_result$dist_cat = factor(tripsTable_result$dist_cat,levels = c("0-1km","1-2km","2-5km","5-10km","10-20km","20-50km","50-100km","> 100km")) + return(tripsTable_result) +} + +#' Deprecated function(s) in the matsimr package +#' +#' \strong{filterByRegion} - Filtering of trips_table(from \link{read_output_trips}) depending on how they located in given shape\cr +#' 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: \cr +#' if start.inshape = TRUE & end.inshape = TRUE return table that contains trips inside given shape\cr +#' if start.inshape = TRUE & end.inshape = FALSE return table that contains trips which starts in shape and ends out of the shape\cr +#' if start.inshape = FALSE & end.inshape = TRUE return table that contains trips which ends in shape and starts out of the shape\cr +#' if start.inshape = FALSE & end.inshape = FALSE return table that contains trips which starts and ends our of the given shape +#' +#' @rdname matsimr-deprecated +#' +#' @param tripsTable tibble of trips_output (from \link{read_output_trips}) +#' +#' @param shapeTable sf object(data.frame with geometries), can be received by using st_read(path_to_geographical_file) +#' +#' @param crs numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation +#' +#' @param start.inshape bool, defines trips to conclude (see Description) +#' +#' @param end.inshape bool, defines trips to conclude (see Description) +#' +#' @return \strong{filterByRegion} - tibble, with filtered trips depending on shapeTable and special flags (see Description) +#' +#' @export +filterByRegion <- function(tripsTable, + shapeTable, + crs, + start.inshape = TRUE, end.inshape = TRUE) { + .Deprecated("process_filter_by_shape") + # shapeTable <- st_read(shapeFile) + if (st_crs(shapeTable) == NA) { + st_crs(shapeTable) <- crs + } + + sf_table <- transformToSf(tripsTable, crs = crs, geometry.type = st_point()) + shapeTable <- st_transform(shapeTable, crs = crs) + # shapeTable isn't table - shape + + union_shape <- st_union(shapeTable) # transforms the crs back to the previous in the file + union_shape <- st_transform(union_shape, crs = st_crs(shapeTable)) + + + st_geometry(sf_table) <- "start_wkt" # Set start_wkt as an active geometry + cont1 <- st_contains(union_shape, sf_table)[[1]] # Indexes of rows where start point is in shapefile + + st_geometry(sf_table) <- "end_wkt" # Set end_wkt as and active geometry + cont2 <- st_contains(union_shape, sf_table)[[1]] # Indexes of rows where end point is in shapefile + + # get trips that ended outside of shape + cont_end_outside <- setdiff(1:nrow(sf_table), cont2) + + # get trips that started outside of shape + cont_start_outside <- setdiff(1:nrow(sf_table), cont1) + + if (start.inshape == TRUE && end.inshape == TRUE) { + cont_union <- intersect(cont1, cont2) + } else if (start.inshape == TRUE && end.inshape == FALSE) { + cont_union <- intersect(cont1, cont_end_outside) + } else if (start.inshape == FALSE && end.inshape == TRUE) { + cont_union <- intersect(cont2, cont_start_outside) + } else { + cont_union <- intersect(cont_start_outside, cont_end_outside) # Give back trips that are neither starting and ending outside the area + } + + + return(tripsTable[cont_union, ]) +} + + + +#' Deprecated function(s) in the matsimr package +#' +#' \strong{deriveODMatrix} - Creates an instance of ODMatrix(origin/destination) in conventional form or for the simwrapper +#' +#' @rdname matsimr-deprecated +#' +#' @param tripsTable table of output trips(from \link{read_output_trips}) or path to trips_output file +#' +#' @param shapePath full path to shapefile (if simwrapper TRUE, folder with shapeFile should contain also .dbf with the same name) +#' +#' @param crs numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation +#' +#' @param dump.output.to path to a folder to save csv file of ODMatrix +#' +#' @param 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 +#' +#' @param simwrapper create output in a simwrapper form if set to path of the shapefile +#' +#' @param outer logical that represent if the table should contain outside flow of the shape, it isn't +#' +#' @return \strong{deriveODMatrix} - tibble of origin/destination matrix +#' +#' @export +deriveODMatrix<- function(tripsTable, + shapePath, + crs, + dump.output.to = matsimDumpOutputDirectory, + simwrapper = FALSE, + colnames = "numeric", + outer = FALSE){ + .Deprecated("process_get_OD_matrix") + defaultW <- getOption("warn") + options(warn = -1) + + #if tripstable given as folder/file + if(sum(class(tripsTable) %in% c("tbl_df","tbl","data.frame"))<1){ + tripsTable <- readTripsTable(tripsTable) + } + + sfTable <- transformToSf(tripsTable,crs,geometry.type = st_point()) + + shape = st_read(shapePath) + + if (st_crs(shape) == NA) { + st_crs(shape) <- crs + } + shape = st_transform(shape,crs = crs) + + sf_table <- transformToSf(tripsTable, crs = crs, geometry.type = st_point()) + + sf_start = sfTable %>% select(trip_id,start_wkt) + st_geometry(sfTable) = "end_wkt" + sf_end = sfTable %>% select(trip_id,end_wkt) + + #Get all inner intersects + sf_intersect_start = st_contains(shape,sf_start) + sf_intersect_end = st_contains(shape,sf_end) + + + if(outer == TRUE){ + #Get all outer intersects + joined_shape = st_union(shape) + + start_inside = st_contains(joined_shape,sf_start) + end_inside = st_contains(joined_shape,sf_end) + + start_outside = 1:nrow(sf_start) + end_outside = 1:nrow(sf_end) + + start_outside = start_outside[! start_outside %in% start_inside[[1]]] + + end_outside = end_outside[! end_outside %in% end_inside[[1]]] + + sf_intersect_start = append(sf_intersect_start,list(start_outside)) + sf_intersect_end = append(sf_intersect_end,list(end_outside)) + } + + # Create matrix out of it + result_tibble = as_tibble(data.frame(matrix(nrow=0,ncol=nrow(shape)))) + colnames(result_tibble) = 1:nrow(shape) + + for(i in 1:length(sf_intersect_start)){ + temp = c() + for(j in 1:length(sf_intersect_start)){ + start_i = sf_intersect_start[[i]] + end_j = sf_intersect_end[[j]] + + number_of_trips = length(intersect(start_i,end_j)) + + temp = append(temp,number_of_trips) + + } + result_tibble = rbind(result_tibble,temp) + } + + if(colnames!="numeric" & colnames %in% colnames(shape)){ + colnames(result_tibble) = shape[[colnames]] + if(outer == TRUE){ + rownames(result_tibble) = c(shape[[colnames]],"outer") + colnames(result_tibble)[length(colnames(result_tibble))] = "outer" + }else{ + rownames(result_tibble) = shape[[colnames]] + } + + }else{ + colnames(result_tibble) = sapply(1:length(sf_intersect_start),as.character) + rownames(result_tibble) = sapply(1:length(sf_intersect_start),as.character) + } + + + result_melt = melt(as.matrix(result_tibble)) + colnames(result_melt) = c("origin","destination",1) + # Generating yaml and output_files + + + + if (file.exists(dump.output.to) & simwrapper == TRUE) { + write.table(result_melt,paste0(dump.output.to,"/ODMatrix.csv"),row.names = FALSE,sep = ";") + } else if(!file.exists(dump.output.to) & simwrapper == TRUE) { + dir.create(dump.output.to) + write.table(result_melt,paste0(dump.output.to,"/ODMatrix.csv"),row.names = FALSE,sep = ";") + } else if (file.exists(dump.output.to) & simwrapper == FALSE) { + write_csv2(result_tibble,paste0(dump.output.to,"/ODMatrix.csv")) + } else { + dir.create(dump.output.to) + write_csv2(result_tibble,paste0(dump.output.to,"/ODMatrix.csv")) + } + + yaml_list <- list( + title = "OD Flow", + description = "generated by deriveODMatrix", + projection = st_crs(shape)$input, + shpFile = paste0("../",shapePath), + dbfFile = paste0("../",substr(shapePath,start = 1,stop = nchar(shapePath)-3),"dbf"), + scaleFactor = 1, + lineWidth = 50, + csvFile = "ODMatrix.csv", + idColumn = colnames(shape)[1] # at the moment idColumn of shapefile should be the first column + + ) + write_yaml(yaml_list, paste0(dump.output.to, "/viz-od-flow.yaml")) + + options(warn = defaultW) + return(result_tibble) +} + +#' Deprecated function(s) in the matsimr package +#' +#' \strong{getCrsFromConfig} - Reads an coordinate reference system of MATSim output directory +#' from output_config.xml +#' +#' @rdname matsimr-deprecated +#' +#' @param folder specifies path to find config +#' +#' +#' @return \strong{getCrsFromConfig} - code of coordinate reference system +#' +#' @export +getCrsFromConfig <- function(folder) { + + if (grepl("output_config.xml$", folder) == TRUE) + { + config <- read_xml(folder) + + param_nodes = xml_find_all(config,"//param") + + coord_node = param_nodes[xml_attr(param_nodes,"name") == "coordinateSystem"] + + coord_system = xml_attr(coord_node,"value") + return(coord_system) + } + + files <- list.files(folder, full.names = TRUE) + # Read from global/local directory + # output_config.xml is contained as output_trips.csv.gz + if (length(grep("output_config.xml$", files)) != 0) { + config <- read_xml(files[grep("output_config.xml$", files)]) + + param_nodes = xml_find_all(config,"//param") + + coord_node = param_nodes[xml_attr(param_nodes,"name") == "coordinateSystem"] + + coord_system = xml_attr(coord_node,"value") + return(coord_system) + } + return(NA) +} + + +#' Deprecated function(s) in the matsimr package +#' +#' \strong{transformToSf} - Transforms trips_table tibble (from \link{read_output_trips}) from tibble to sf (table with attribute features and geometry feature)\cr +#' Takes trips_table (from \link{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.\cr +#' And adds wkt column, if geometry.type = st_mulitpoint(), or geometry.type = st_linestring()\cr +#' Or adds start_wkt and end_wkt, if geometry.type = st_point()\cr +#' Added column/columns projected to given CRS (coordinate reference system), +#' that can be taken from network file of MATSimOutputDirectory\cr +#' 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 +#' +#' @rdname matsimr-deprecated +#' +#' @param table tibble of trips_output (from \link{read_output_trips}) +#' +#' @param crs numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation +#' +#' @param geometry.type function of sf transformation, geometry.type can be (by default is st_multipoint())\cr +#' !!!st_point()-resulting table contains 2 geometries start_wkt and end_wkt, representing start and end POINTs, and have type POINT!!! or \cr +#' !!!st_multipoint()-resulting table contains 1 geometry wkt, representing start and end POINTS as MULTIPOINT!!! or \cr +#' !!!st_linestring() - resulting table contains 1 geometry wkt, representing line between start and end points as LINESTRING!!! +#' +#' @return \strong{transformToSf} - sf object (data.frame with geometries depending to geometry.type) +#' +#' @export +transformToSf <- function(table, + crs, + geometry.type = st_multipoint()) { + + .Deprecated("process_convert_table_to_sf") + + if (class(geometry.type)[2] == "POINT") { + table1 <- table %>% + # mutate(wkt = paste("MULTIPOINT(", start_x, " ", start_y, ",", end_x, " ", end_y, ")", sep ="")) + mutate(start_wkt = paste("POINT(", start_x, " ", start_y, ")", sep = "")) + table2 <- table %>% + mutate(end_wkt = paste("POINT(", end_x, " ", end_y, ")", sep = "")) + attr(table, "geometry.type") <- "POINT" + + + table1_wkt <- st_as_sf(table1, wkt = "start_wkt") %>% select(-start_x, -start_y, -end_x, -end_y) + table2_wkt <- st_as_sf(table2, wkt = "end_wkt") %>% select(-start_x, -start_y, -end_x, -end_y) + + + result_table <- table1_wkt %>% mutate(end_wkt = table2_wkt$end_wkt) + st_geometry(result_table) <- "start_wkt" + st_crs(result_table) <- crs + st_geometry(result_table) <- "end_wkt" + st_crs(result_table) <- crs + st_geometry(result_table) <- "start_wkt" + return(result_table) + } else if (class(geometry.type)[2] == "MULTIPOINT") { + table <- table %>% + mutate(wkt = paste("MULTIPOINT(", start_x, " ", start_y, ",", end_x, " ", end_y, ")", sep = "")) + attr(table, "geometry.type") <- "MULTIPOINT" + + + result_table <- st_as_sf(table, wkt = "wkt") %>% select(-start_x, -start_y, -end_x, -end_y) + + st_crs(result_table) <- crs + return(result_table) + } else if (class(geometry.type)[2] == "LINESTRING") { + table <- table %>% + mutate(wkt = paste("LINESTRING(", start_x, " ", start_y, ",", end_x, " ", end_y, ")", sep = "")) + attr(table, "geometry.type") <- "LINESTRING" + + + result_table <- st_as_sf(table, wkt = "wkt") %>% select(-start_x, -start_y, -end_x, -end_y) + + st_crs(result_table) <- crs + return(result_table) + } else { + return(NA) + } +} + + +#####Reading##### + + +#' Load MATSim output_trips table into memory +#' +#' Loads MATSim output_trips.csv from file or archive creating a tibble +#' +#' @param input_path character string, path to the MATSim output directory or http link to the file +#' @param n_max optional, integer, maximum number of lines to read, standard value is Inf +#' @return tibble of output_trips +#' +#' @export +read_output_trips <- function(input_path = ".", n_max = Inf) { + options(digits = 18) + trips_file <- "" + + # if input_path is a directory, find the correct file path within it + if(dir.exists(input_path)){ + files <- list.files(input_path, full.names = TRUE) + trip_file_indicies <- grep("output_trips.csv.gz$", files) + + if(length(trip_file_indicies) == 1){ + trips_file <- files[trip_file_indicies] + } else { + stop('There is supposed to be a single "output_trips.csv.gz" found in directory') + } + } else { + trips_file <- input_path + } + + trips_output_table <- read_delim(trips_file, + delim = ";", + locale = locale(decimal_mark = "."), + n_max = n_max, + col_types = cols( + start_x = col_character(), + start_y = col_character(), + end_x = col_character(), + end_y = col_character(), + end_link = col_character(), + start_link = col_character() + ) + ) + # person is mostly integer, but contains also chars(see Hamburg 110813 observation) + + # doesn't read coordinates correctly + trips_output_table <- trips_output_table %>% + mutate( + start_x = as.double(start_x), + start_y = as.double(start_y), + end_x = as.double(end_x), + end_y = as.double(end_y) + ) + attr(trips_output_table,"table_name") <- trips_file + return(trips_output_table) + +} + + + +#####Plotting##### + +#' Plot the distribution of modes as a pie chart +#' +#' Uses the dataframe trips_output (from \link{read_output_trips}), +#' to plot a pie chart of the modal split using the column main_mode +#' +#' The function automatically detects the modes plots a pie chart. +#' Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') +#' +#' @param trips_table tibble of trips_output (from \link{read_output_trips}) +#' @param unite_modes vector of character strings, +#' changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +#' using the function (\link{process_rename_mainmodes}) +#' @param united_name character string, specifies the name of the united mode +#' +#' @return pie chart plot of transport mode distribution, values given in percent +#' +#' @export +plot_mainmode_piechart <- function(trips_table, + unite_modes = character(0), united_name = "united") { + + # renaming/uniting of modes + trips_table = process_rename_mainmodes(trips_table = trips_table, + unite_modes = unite_modes, + united_name = united_name) + + # processing + # calculates the mode share and saves it as a tibble + trips_table_count<-process_get_mainmode_distribution(trips_table, + percentage= FALSE) + + + # plotting + fig <- plot_ly(trips_table_count, labels = ~main_mode, values = ~n, type = 'pie') + fig <- fig %>% layout(title = 'Main mode distribution', + xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE), + yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE)) + + return(fig) +} + + +#' Plot the distribution of modes as a bar chart +#' +#' Takes the data frame trips_output (from \link{read_output_trips}) +#' to plot a bar chart of the modal split using the column main_mode. +#' +#' The modal shares are given in percentages. +#' +#' Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') +#' +#' +#' @param trips_table tibble of trips_output (from \link{read_output_trips}) +#' @param unite_modes vector of character strings, +#' changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +#' using the function (\link{process_rename_mainmodes}) +#' @param united_name character string, specifies the name of the united mode +#' @param percentage boolean, by default FALSE, sets if output is given in percentage +#' +#' @return Bar Chart plot of transport mode distribution, values given in percents +#' +#' @export +plot_mainmode_barchart <- function(trips_table, + unite_modes = character(0), + united_name = "united", + percentage = FALSE) { + + # renaming/uniting of modes + trips_table <- process_rename_mainmodes(trips_table = trips_table, + unite_modes = unite_modes, + united_name = united_name) + # processing + # calculates the mode share and saves it as a tibble + trips_table_count <- process_get_mainmode_distribution(trips_table, + percentage = percentage) + + # plotting + fig = plot_ly(data = trips_table_count,x = ~main_mode,y = ~n,type = "bar", + text=trips_table_count$n, + textposition = "auto", + name = "Main mode distribtion") + fig = fig %>% layout(yaxis = list(title = "Count"),barmode = "group") + fig + return(fig) +} + +#' Plot travel and wait time for each mode as a bar chart +#' +#' Takes the data frame trips_output (from \link{read_output_trips}), +#' to plot a bar chart of travel and wait times. +#' Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') +#' +#' +#' @param trips_table tibble of trips_output (from \link{read_output_trips}) +#' @param unite_modes vector of character strings, +#' changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +#' using the function (\link{process_rename_mainmodes}) +#' @param united_name character string, specifies the name of the united mode +#' @param time_format A character string indicating the desired time format for the output. +#' The options are "minute", "hour", or "second". The default is "minute". +#' +#' @return Bar Chart plot of average time spent on travel/wait +#' +#' @export +plot_travelwaittime_mean_barchart <- function(trips_table, + unite_modes = character(0), + united_name = "united", + time_format = "minute") { + + # renaming/uniting of modes + trips_table <- process_rename_mainmodes(trips_table = trips_table, + unite_modes = unite_modes, + united_name = united_name) + + #processing + avg_time = process_get_travelwaittime_by_mainmode(trips_table,time_format = time_format) + + #plotting + fig = plot_ly(data = avg_time,x = ~main_mode,y = ~trav_time_avg,type = 'bar',name = "AVG Time Travelling", + text = round(avg_time$trav_time_avg,2)) + fig = fig %>% add_trace(y = ~wait_time_avg,name = "AVG Time Waiting", + text = round(avg_time$wait_time_avg,2)) + fig = fig %>% layout(yaxis = list(title = paste0("Time spent (in ",time_format,"s)"),barmode = "group")) + + + fig + return(fig) + +} + + + + + + + +#' Bar Chart with distance traveled on x-axis and number of trips on y-axis +#' +#' Takes the data frame trips_output (from \link{read_output_trips}) and categorizes the traveled distances into pre-defined bins +#' to plot a histogram of the traveled distances. (Bins: 1000,2000,5000,10000,20000,50000,100000 (m)) +#' Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') +#' +#' +#' @param trips_table tibble of trips_output (from \link{read_output_trips}) +#' @param unite_modes vector of character strings, +#' changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +#' using the function (\link{process_rename_mainmodes}) +#' @param united_name character string, specifies the name of the united mode +#' @param dist_column A character string specifying the column name in the trips_table tibble that contains the distance categories. +#' @param distances_array A numeric vector defining the distance thresholds for creating distance categories. +#' +#' @return Plotly bar Chart of count of trips among distance travelled +#' +#' @export +plot_distcat_by_mainmode_barchart <- function(trips_table, + unite_modes = character(0), + united_name = "united", + dist_column = "dist_cat", + distances_array = c(1000,2000,5000,10000,20000,50000,100000)) { + + + # renaming/uniting of modes + trips_table <- process_rename_mainmodes(trips_table = trips_table, + unite_modes = unite_modes, + united_name = united_name) + + #processing + trips_table <- process_append_distcat(trips_table =trips_table, + distances_array = distances_array) + + + #plotting + plt = ggplot(trips_table) + + geom_bar(aes(x = dist_cat,fill = main_mode),position = position_dodge())+ + ggtitle("Number of trips per travelling distance") + fig = plotly::ggplotly(plt) + + fig + return(fig) + +} + +#' Bar chart with average distance traveled for each mode on x-axis and number of trips on y-axis +#' +#' Takes the data frame trips_output (from \link{read_output_trips}), +#' to plot a bar chart of the average distance traveled for each main mode, +#' Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') +#' +#' +#' @param trips_table tibble of trips_output (from \link{read_output_trips}) +#' @param unite_modes vector of character strings, +#' changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +#' using the function (\link{process_rename_mainmodes}) +#' @param united_name character string, specifies the name of the united mode +#' @param euclidean Logical value indicating whether to calculate the average as euclidean distance or as travel distance. Default is FALSE, which calculates the average traveled distance. +#' +#' @return Bar Chart plot of distance traveled per mode +#' +#' @export +plot_distance_by_mainmode_barchart <- function(trips_table, + unite_modes = character(0), united_name = "united", + euclidean = FALSE) { + + + # renaming/uniting of modes + trips_table <- process_rename_mainmodes(trips_table = trips_table, + unite_modes = unite_modes, + united_name = united_name) + + #processing + trips_table <- process_get_travdistance_distribution(trips_table = trips_table,euclidean = euclidean) + + + #if(only.process){ + # return(trips_table) + #} + + #plotting + text_for_y <- round(trips_table$avg_dist,digits = 2) + fig <- plot_ly(data = trips_table,x = ~main_mode,y = ~avg_dist, + + type = 'bar', + text = text_for_y, + textposition = "auto", + name = paste0("AVG " ,if_else(euclidean,"eucliden ","traveled ") ,"distance by mode over a day")) + fig <- fig %>% layout(yaxis = list(title = "Distance (in meters)"),barmode = "group") + + fig + return(fig) +} + + +#' Plots distribution of every type of trip(inside, outside, origin and destinating) as a pie chart +#' +#' @param trips_table tibble of trips_output (from \link{read_output_trips}) +#' @param shape_Table sf object(data frame with geometries), can be created using st_read(), is used to categorize the trips. +#' @param crs numeric representation of the EPSG code or proj4string for the corresponding coordinate system of the trip coordinates, +#' can be found in network file from output directory of MATSim simulation +#' +#' @return Pie chart showing the percentage of each type of trip +#' +#' @export +plot_spatialtype_by_shape_piechart <- function(trips_table, shape_table, crs) { + + trips_table <- process_append_spatialcat(trips_table,shape_table = shape_table,crs = crs) + + #print(trips_table) + + + trips_table_distribution <- trips_table %>% count(spatial_category) + + #print(trips_table_distribution) + + fig <- plot_ly(trips_table_distribution, labels = ~spatial_category, values = ~n, type = 'pie') + fig <- fig %>% layout(title = 'Spatial type distribution', + xaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE), + yaxis = list(showgrid = FALSE, zeroline = FALSE, showticklabels = FALSE)) + fig + + +} + +#' Bar Chart with tripType on x-axis and travelled distance on y-axis +#' +#' Takes Table trips_output (from \link{read_output_trips}), +#' to plot bar chart with with values that represent +#' travelled distance of each tripType related to the shapeTable +#' +#' +#' @param trips_table tible of trips_output (from \link{read_output_trips}) +#' @param shape_Table sf object(data frame with geometries), can be created using st_read(), is used to categorize the trips. +#' @param crs numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation +#' @param euclidean Logical value indicating whether to calculate the average as euclidean distance or as travel distance. Default is FALSE, which calculates the average traveled distance. +#' +#' @return Bar Chart plot of distance traveled by spatial type +#' +#' @export +plot_distance_by_spatialcat_barchart <- function(trips_table, shape_table, crs, euclidean = FALSE) { + + #processing + + trips_table<- process_append_spatialcat(trips_table,shape_table, crs = crs) + travelled = trips_table %>% group_by(spatial_category) %>% summarize(travelled = sum(traveled_distance)/1000) + + #For plotting + fig = plot_ly(data = travelled,x = ~spatial_category,y = ~travelled,type = 'bar',name = "Distance travelled by trip Type") + fig = fig %>% layout(yaxis = list(title = "Distance travelled (in kms)"),barmode = "group") + fig + return(fig) +} + +#' Line plot with departure time on x-axis and number of trips on y-axis +#' +#' Takes data frame trips_output (from \link{read_output_trips}), +#' to create a line plot of the number of trips for a specific departure time by main_mode +#' Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') +#' +#' +#' @param trips_table tibble of trips_output (from \link{read_output_trips}) +#' @param unite_modes vector of character strings, +#' changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +#' using the function (\link{process_rename_mainmodes}) +#' @param united_name character string, specifies the name of the united mode +#' @return Line plot of trips count by departure time per mode +#' +#' @export +plot_trips_count_by_deptime_and_mainmode_linechart <- function(trips_table, + unite_modes = character(0), + united_name = "united") { + + + # If some columns should be united + trips_table <- process_rename_mainmodes(trips_table = trips_table, + unite_modes = unite_modes, + united_name = united_name) + + + #processing + trips_table = trips_table %>% + mutate(dep_time = hour(dep_time)) %>% + count(dep_time,main_mode) + + + #plotting + fig = plot_ly(trips_table,x = ~dep_time,y = ~n,type = "scatter",mode = "line",linetype = ~main_mode) + fig = fig %>% layout(yaxis = list(title = "Count of trips per departure Time"),barmode = "group") + + fig + return(fig) +} + + +#' Plot Arrival Time by Activity +#' +#' \strong{plot_arrtime_by_act} - Takes Table trips_output (from \link{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') +#' +#' +#' @param trips_table tibble of trips_output (from \link{read_output_trips}) +#' @param unite_activities vector of character strings, that represent patterns of columns to be united, changes name of all activity types in the tibble copy to united_name = "united" that matches PATTERNS given in unite.columns +#' @param united_name character string, if columns were united, you can specify name for the resulting column in plot +#' +#' @return A plotly object representing the line plot of arrival time by activity. +#' +#' @export +plot_arrtime_by_act <- function(trips_table, unite_activities = character(0), united_name = "united") { + + + + # If some columns should be united + trips_table <- process_rename_category(trips_table = trips_table, + unite_template = unite_activities, + united_name = united_name, + column = "end_activity_type") + + + trips_table = trips_table %>% + mutate(arr_time = hour(hms(trips_table$dep_time)+hms(trips_table$trav_time))) %>% + mutate(end_activity_type = sapply(strsplit(end_activity_type,"_"),"[[",1)) %>% + count(arr_time,end_activity_type) + + + activities = levels(factor(trips_table$end_activity_type)) + + + + fig = plot_ly(trips_table,x = ~arr_time,y = ~n,type = "scatter",mode = "line",linetype = ~end_activity_type) + fig = fig %>% layout(yaxis = list(title = "Number of trips ending per trip purpose / Count of activities starting"), + xaxis = list(title = "Time [h]"), + barmode = "group") + + + fig + return(fig) + +} + + +#' Plot Departure Time by Activity +#' +#' The \code{plot_deptime_by_act} function generates a line plot to visualize the departure time of trips by activity in a given trips_table tibble. +#' It provides insights into the number of trips starting at different times for each activity. +#' +#' @param tripsTable tibble of trips_output (from \link{read_output_trips}) +#' @param unite_activities vector of character strings, that represent patterns of columns to be united, changes name of all activity types in the tibble copy to united_name = "united" that matches PATTERNS given in unite_columns +#' @param united_name character string, if columns were united, you can specify name for the resulting column in plot +#' +#' @return A plotly object representing the line plot of departure time by activity. +#' +#' @export +plot_deptime_by_act <- function(trips_table, unite_activities = character(0), united_name = "united") { + + + # If some columns should be united + trips_table <- process_rename_category(trips_table = trips_table, + unite_template = unite_activities, + united_name = united_name, + column = "end_activity_type") + + + trips_table = trips_table %>% + mutate(dep_time = hour(dep_time)) %>% + mutate(end_activity_type = sapply(strsplit(end_activity_type,"_"),"[[",1)) %>% + count(dep_time,end_activity_type) + + + + + fig = plot_ly(trips_table,x = ~dep_time,y = ~n,type = "scatter",mode = "line",linetype = ~end_activity_type) + fig = fig %>% layout(yaxis = list(title = "Number of trips ending per trip purpose / Count of activities starting"), + xaxis = list(title = "Time [h]"), + barmode = "group") + + + fig + return(fig) + +} + + +###### Compare ###### + +#' Bar chart comparing distance traveled on x-axis and number of trips on y-axis for two different runs + +#' Takes two data frames (from \link{read_output_trips}), categorizes the traveled distances into pre-defined bins +#' and plots the difference in number of trips for each bin. (Bins: 1000,2000,5000,10000,20000,50000,100000 (m)) +#' Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') +#' +#' +#' @param trips_table1 tibble of trips_output (from \link{read_output_trips}), number of trips of this table will be extracted from number of trips of tripsTable1 +#' @param trips_table2 tibble of trips_output (from \link{read_output_trips}), from number of trips of this table number of trips of tripsTable1 will be extracted +#' @param unite_modes vector of character strings, +#' changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +#' using the function (\link{process_rename_mainmodes}) +#' @param united_name character string, specifies the name of the united mode +#' @param dist_column A character string specifying the column name in the trips_table tibble that contains the distance categories. +#' @param distances_array A numeric vector defining the distance thresholds for creating distance categories. +#' +#' @return Bar Chart plot of count of trips among distance travelled +#' +#' @export +plot_compare_distcat_by_mainmode_barchart <- function(trips_table1,trips_table2, + unite_modes = character(0), united_name = "united", + dist_column = "dist_cat", + distances_array = c(1000,2000,5000,10000,20000,50000,100000)) { + + trips_table1 <- process_rename_mainmodes(trips_table = trips_table1, + unite_modes = unite_modes, + united_name = united_name) + + trips_table2 <- process_rename_mainmodes(trips_table = trips_table2, + unite_modes = unite_modes, + united_name = united_name) + + modes = unique(c(unique(trips_table1$main_mode),unique(trips_table2$main_mode))) + + distribution1 <- process_append_distcat(trips_table1,distances_array = distances_array) + distribution2 <- process_append_distcat(trips_table2,distances_array = distances_array) + + + #Get category count difference + + table_with_counts1 = distribution1 %>% count(main_mode,dist_cat) + table_with_counts2 = distribution2 %>% count(main_mode,dist_cat) + + joined <- full_join(table_with_counts1, table_with_counts2, by = c("main_mode", "dist_cat")) + + result <- joined %>% + replace_na( list(n.x = 0, n.y = 0) ) %>% + mutate(n = n.y - n.x) %>% + select(main_mode, dist_cat, n) + + + result$dist_cat = factor(result$dist_cat,levels = distances_array) + + + fig = ggplotly(ggplot(result) + + geom_col(aes(x = dist_cat,fill = main_mode, y = n), position = position_dodge())+ + ggtitle("Difference in number of trips per travelling distance")) + + + return(fig) + +} + + + +#' Plot bar chart of changes in modal split +#' +#' Takes two data frames (from \link{read_output_trips}), calculates the +#' changes in mode shares and plots them as a bar chart +#' Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') +#' +#' +#' +#' @param trips_table1 tibble of trips_output (from \link{read_output_trips}) +#' @param trips_table2 tibble of trips_output (from \link{read_output_trips}) +#' @param unite_modes vector of character strings, +#' changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +#' using the function (\link{process_rename_mainmodes}) +#' @param united_name character string, specifies the name of the united mode +#' +#' @return plots bar chart of changes in modal split +#' +#' @export +plot_compare_mainmode_barchart <- function(trips_table1, trips_table2, + unite_modes = character(0), + united_name = "united") { + # renaming/uniting of modes + + trips_table1 <- process_rename_mainmodes(trips_table = trips_table, + unite_modes = unite_modes, + united_name = united_name) + + trips_table2 <- process_rename_mainmodes(trips_table = trips_table, + unite_modes = unite_modes, + united_name = united_name) + + trips_table1 = trips_table1 %>% mutate(type = "base") + trips_table2 = trips_table2 %>% mutate(type = "policy") + + total_trips = rbind(trips_table1,trips_table2) + + plt = ggplot(total_trips, aes(x =main_mode,fill = factor(type)))+ + geom_bar(position = position_dodge())+ + coord_flip() + plotly::ggplotly(plt) + + return(plotly::ggplotly(plt)) +} + +#' Plot alluvial/sankey diagram of transport mode changes +#' +#' Takes two data frames (from \link{read_output_trips}) and compares the mode choice for each agent and summarizes the results, showing the modal shift. +#' Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') +#' The parameter show.onlyChanges allows the visualization of only the mode shift (excluding the trips that do not change mode). Standard value is FALSE. +#' +#' @param trips_table1 tibble of trips_output (from read_output_trips()) +#' @param trips_table2 tibble of trips_output (from read_output_trips()) +#' @param show_onlychanges boolean, if it is set to TRUE the sankey diagram only shows the mode shift +#' @param unite_modes vector of character strings, +#' changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +#' using the function (\link{process_rename_mainmodes}) +#' @param united_name character string, specifies the name of the united mode +#' +#' @return Alluvial diagram that represents changes in transport mode distribution +#' +#' @export +plot_compare_mainmode_sankey <- function(trips_table1, trips_table2, + show_onlychanges = FALSE, + unite_modes = character(0), + united_name = "united") { + + # renaming/uniting of modes + trips_table1 <- process_rename_mainmodes(trips_table = trips_table1, + unite_modes = unite_modes, + united_name = united_name) + + trips_table2 <- process_rename_mainmodes(trips_table = trips_table2, + unite_modes = unite_modes, + united_name = united_name) + #processing + joined <- as_tibble(inner_join(trips_table1, trips_table2 %>% + select(trip_id, main_mode), by = "trip_id") %>% + dplyr::rename(base_mode = main_mode.x, policy_mode = main_mode.y)) + + #if onlychanges, then we should exclude base_mode=policy_mode + if (show_onlychanges == TRUE) { + joined <- joined %>% + filter(base_mode != policy_mode) + } + + joined <- joined %>% + group_by(base_mode, policy_mode) %>% + count() + + modes = unique(c(joined$base_mode,joined$policy_mode)) + + joined$base_mode <- as.numeric(factor(joined$base_mode,levels = modes)) + joined$policy_mode <- as.numeric(factor(joined$policy_mode,levels = modes)) + + + #plotting + palette <- colorRampPalette( c( "blue", "red" ) )( 7 ) + + + fig <- plot_ly( + type = "sankey", + orientation = "h", + + node = list( + label = c(modes,modes), + color = c(palette,palette), + pad = 15, + thickness = 20, + line = list( + color = "black", + width = 0.5 + ) + ), + + link = list( + source = joined$base_mode-1, + target = joined$policy_mode+6, + value = joined$n + ) + ) + fig <- fig %>% layout( + title = "Basic Sankey Diagram", + font = list( + size = 10 + ) + ) + + fig + return(fig) +} + +#' Comparison bar chart with main_mode on x-axis and average travel/wait time on y-axis +#' +#' Takes the data frame trips_output (from \link{read_output_trips}), +#' to plot a bar chart of the traveling/waiting time +#' Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') +#' +#' +#' @param trips_table1 tibble of trips_output (from \link{read_output_trips}) +#' @param trips_table2 tibble of trips_output (from \link{read_output_trips}) +#' @param unite_modes vector of character strings, +#' changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +#' using the function (\link{process_rename_mainmodes}) +#' @param united_name character string, specifies the name of the united mode +#' @param time_format character string, defines time format to be used(takes "hour", "minute", "second") +#' +#' @return Bar chart plot of average travel/wait time +#' +#' @export +plot_compare_travelwaittime_by_mainmode_barchart <- function(trips_table1,trips_table2, + + unite_modes = character(0), + united_name = "united", + time_format = "minute") { + + #TODO: + # . Document and add title to show what means positive/negative value + # . think about comparing processing functions they can appear in future often + + + # If some columns should be united + trips_table1 <- process_rename_mainmodes(trips_table = trips_table1, + unite_modes = unite_modes, + united_name = united_name) + + trips_table2 <- process_rename_mainmodes(trips_table = trips_table2, + unite_modes = unite_modes, + united_name = united_name) + + #processing + avg_time1 = process_get_travelwaittime_by_mainmode(trips_table1,time_format = time_format) + + + + avg_time2 = process_get_travelwaittime_by_mainmode(trips_table2,time_format = time_format) + + + avg_time = full_join(avg_time1, avg_time2, by = "main_mode") %>% + replace_na(list(trav_time_avg.x = 0,wait_time_avg.x = 0,trav_time_avg.y = 0,wait_time_avg.y = 0)) + + + + avg_time = avg_time %>% mutate(trav_time_avg = trav_time_avg.x - trav_time_avg.y, + wait_time_avg =wait_time_avg.x - wait_time_avg.y )%>% + select(-wait_time_avg.x,-wait_time_avg.y, -trav_time_avg.x,-trav_time_avg.y) + + + + #plotting + fig = plot_ly(data = avg_time,x = ~main_mode,y = ~trav_time_avg,type = 'bar',name = "AVG Time Travelling") + fig = fig %>% add_trace(y = ~wait_time_avg,name = "AVG Time Waiting") + fig = fig %>% layout(yaxis = list(title = paste0("Time spent (in ",time_format,"s)")),barmode = "group") + + + fig + return(fig) + +} + + + +#' Plot Comparison of Count by Spatial Category (Bar Chart) +#' +#' The \code{plot_compare_count_by_spatialcat_barchart} +#' function generates a bar chart to compare the count of trips between two trips_table +#' tibbles across different spatial categories. +#' It provides insights into the distribution of trips across spatial categories for each table. +#' +#' +#' @param trips_table1 tible of trips_output (from \link{read_output_trips}) +#' @param trips_table2 tible of trips_output (from \link{read_output_trips}) +#' @param shape_table A spatial shapefile or spatial polygons data frame used to create the spatial categories. +#' @param crs numeric representation of the EPSG code or proj4string for the corresponding coordinate system of the trip coordinates, +#' can be found in network file from output directory of MATSim simulation +#' +#' @return A plotly object representing the bar chart of the comparison of count by spatial category. +#' +#' @export +plot_compare_count_by_spatialcat_barchart <- function(trips_table1,trips_table2, shape_table ,crs) { + + spatial_table1 <- process_append_spatialcat(trips_table = trips_table1, + shape_table = shape_table, + crs = crs) + + spatial_table2 <- process_append_spatialcat(trips_table = trips_table2, + shape_table = shape_table, + crs = crs) + + + plt = ggplot(result_table, aes(x =type,fill = factor(table_num)))+ + geom_bar(position = position_dodge())+ + coord_flip() + plotly::ggplotly(plt) + + + return(plotly::ggplotly(plt)) + +} + +#' Bar Chart comparing two runs with main_mode on x-axis and average travel/wait time on y-axis +#' +#' Takes two data frames (from \link{read_output_trips}), +#' to plot a comparison bar chart of travel and wait times. +#' Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') +#' +#' +#' @param trips_table1 tibble of trips_output (from \link{read_output_trips}) +#' @param trips_table2 tibble of trips_output (from \link{read_output_trips}) +#' @param unite_modes vector of character strings, +#' changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +#' using the function (\link{process_rename_mainmodes}) +#' @param united_name character string, specifies the name of the united mode#' +#' @param time_format character string, defines time format to be used(takes "hour", "minute", "second") +#' +#' @return Bar chart plot comparing average time spent on travel/wait of two runs +#' +#' @export +plot_compare_travelwaittime_by_mainmode <- function(trips_table1,trips_table2, + unite_modes = character(0), + united_name = "united", + time_format = "minute") { + + #TODO: + # . Document and add title to show what means positive/negative value + # . think about comparing processing functions they can appear in future often + + + # renaming/uniting of modes + trips_table1 <- process_rename_mainmodes(trips_table = trips_table1, + unite_modes = unite_modes, + united_name = united_name) + + trips_table2 <- process_rename_mainmodes(trips_table = trips_table2, + unite_modes = unite_modes, + united_name = united_name) + + #processing + avg_time1 = process_get_travelwaittime_by_mainmode(trips_table1,time_format = time_format) + + + + avg_time2 = process_get_travelwaittime_by_mainmode(trips_table2,time_format = time_format) + + + avg_time = full_join(avg_time1, avg_time2, by = "main_mode") %>% + replace_na(list(trav_time_avg.x = 0,wait_time_avg.x = 0,trav_time_avg.y = 0,wait_time_avg.y = 0)) + + + + avg_time = avg_time %>% mutate(trav_time_avg = trav_time_avg.x - trav_time_avg.y, + wait_time_avg =wait_time_avg.x - wait_time_avg.y )%>% + select(-wait_time_avg.x,-wait_time_avg.y, -trav_time_avg.x,-trav_time_avg.y) + + + + #plotting + fig = plot_ly(data = avg_time,x = ~main_mode,y = ~trav_time_avg,type = 'bar',name = "AVG Time Travelling") + fig = fig %>% add_trace(y = ~wait_time_avg,name = "AVG Time Waiting") + fig = fig %>% layout(yaxis = list(title = paste0("Time spent (in ",time_format,"s)")),barmode = "group") + + + fig + return(fig) + +} + + + + +###### Mapping ###### + + + +#' Plots start and end coordinates of the given trips table on an osm map +#' +#' @param trips_table tibble of trips_output (from \link{read_output_trips}) +#' +#' @param shape_table spatial +#' @param crs numeric representation of the EPSG code or proj4string for the corresponding coordinate system of the trip coordinates, can be found in network file from output directory of MATSim simulation +#' @param shape_table A spatial shapefile or spatial polygons data frame used as a background. By default NULL. +#' @param optimized bool, by default FALSE and gives interactive plot using leaflet, if TRUE using image with ggplot +#' +#' +#' @return leaflet/ggplot plot with trips start-, end- points +#' +#' @export +plot_map_trips <- function(trips_table, crs,optimized = FALSE, + shape_table = NULL ) { + + table_sf <- process_convert_table_to_sf(trips_table, crs = crs, geometry.type = st_point()) + st_geometry(table_sf) <- "start_wkt" + table_sf_start <- table_sf %>% select(-end_wkt) + st_geometry(table_sf) <- "end_wkt" + table_sf_end <- table_sf %>% select(-start_wkt) + + if(!is.null(shape_table)){ + + if (st_crs(shape_table) == NA) { + ct_crs(shape_table) <- crs + } + shape_table <- st_transform(shape_table, crs = "+proj=longlat +datum=WGS84 +no_defs") + + } + + table_sf_start <- st_transform(table_sf_start, "+proj=longlat +datum=WGS84 +no_defs") + table_sf_end <- st_transform(table_sf_end, "+proj=longlat +datum=WGS84 +no_defs") + + if (optimized) { + colors <- c("Start" = "blue", "End" = "red") + shapes <- c("Start" = 5, "End" = 3) + # ggplot2 isn't interactive! + plt <- ggplot() + + geom_sf(data = table_sf_start, aes(color = "Start"), size = 1, shape = 5) + + geom_sf(data = table_sf_end, aes(color = "End"), size = 1, shape = 3) + + labs(color = "Type") + + scale_colour_manual(values = colors) + + if(!is.null(shape_table)){ + plt <-ggplot() + + geom_sf(data = shape_table)+ + geom_sf(data = table_sf_start, aes(color = "Start"), size = 1, shape = 5) + + geom_sf(data = table_sf_end, aes(color = "End"), size = 1, shape = 3) + + labs(color = "Type") + + scale_colour_manual(values = colors) + } + plt + return(plt) + } + + + plt <- leaflet() %>% + addTiles() %>% + addProviderTiles( + "OpenStreetMap", + # give the layer a name + group = "OpenStreetMap" + ) %>% + addProviderTiles( + "Stamen.Toner", + group = "Stamen.Toner" + ) %>% + addProviderTiles( + "Stamen.Terrain", + group = "Stamen.Terrain" + ) %>% + addProviderTiles( + "Esri.WorldStreetMap", + group = "Esri.WorldStreetMap" + ) %>% + addProviderTiles( + "Wikimedia", + group = "Wikimedia" + ) %>% + addProviderTiles( + "CartoDB.Positron", + group = "CartoDB.Positron" + ) %>% + addProviderTiles( + "Esri.WorldImagery", + group = "Esri.WorldImagery" + ) %>% + addCircleMarkers(table_sf_start, + lng = st_coordinates(table_sf_start$start_wkt)[, 1], + lat = st_coordinates(table_sf_start$start_wkt)[, 2], radius = 3, color = "blue", + label = paste( + "Person_id:", + table_sf_start$person, "
", + "Trip_id:", + table_sf_start$trip_id, "
", + "main_mode:", table_sf_start$main_mode, "
", + "type:", "start", "
", + "Start activity:", + table_sf_start$start_activity_type, "
" + ) %>% lapply(htmltools::HTML) + ) %>% + addCircleMarkers(table_sf_end, + lng = st_coordinates(table_sf_end$end_wkt)[, 1], + lat = st_coordinates(table_sf_end$end_wkt)[, 2], radius = 0.15, color = "red", + label = paste( + "Person_id:", + table_sf_end$person, "
", + "Trip_id:", + table_sf_end$trip_id, "
", + "main_mode:", table_sf_end$main_mode, "
", + "type:", "end", "
", + "End activity:", + table_sf_end$end_activity_type, "
" + ) %>% lapply(htmltools::HTML) + ) %>% + addLegend( + colors = c("blue", "red"), + labels = c("Start of trip", "End of trip"), + position = "bottomleft", + title = "Type of the point", + opacity = 0.9 + ) %>% + addMiniMap() %>% + addLayersControl( + baseGroups = c( + "OpenStreetMap", "Stamen.Toner", + "Stamen.Terrain", "Esri.WorldStreetMap", + "Wikimedia", "CartoDB.Positron", "Esri.WorldImagery" + ), + # position it on the topleft + position = "topleft" + ) + if(!is.null(shape_table)){ + plt = plt %>% addPolygons(data = shape_table, opacity = 0.1, color = "green") + + } + plt + return(plt) +} + + + +#' Plots every type of trips(inside, outside, origin and destinating) on map +#' +#' +#' @param trips_table tibble of trips_output (from \link{read_output_trips}) +#' +#' @param shape_table sf object(data.frame with geometries), can be received by using st_read(path_to_geographical_file) +#' +#' @param crs numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation +#' +#' @param optimized bool, by default FALSE and gives interactive plot using leaflet, if TRUE using image with ggplot +#' +#' @param table tibble of output_trips (from read_output_trips()) +#' @param shape_Table sf object(data frame with geometries), can be created using st_read(), is used to categorize the trips. +#' @param crs numeric representation of the EPSG code or proj4string for the corresponding coordinate system +#' of the trip coordinates, can be found in network file from output directory of MATSim simulation +#' @param optimized bool, by default FALSE and gives interactive plot using leaflet, if TRUE creates image with ggplot +#' @return plot that contains every trip with defined trip type +#' +#' @export +plot_map_trips_by_spatialcat <- function(trips_table, shape_table, + crs, optimized = FALSE) { + + + #processing + + spatial_table <- process_append_spatialcat(trips_table, shape_table = shape_table,crs = crs) + + filtered_sf_inside <- spatial_table %>% filter(spatial_category == "inside") %>% + process_convert_table_to_sf( crs = crs, geometry.type = st_multipoint()) + filtered_sf_origin <- spatial_table %>% filter(spatial_category == "originating") %>% + process_convert_table_to_sf( crs = crs, geometry.type = st_multipoint()) + filtered_sf_destination <- spatial_table %>% filter(spatial_category == "destinating") %>% + process_convert_table_to_sf( crs = crs, geometry.type = st_multipoint()) + filtered_sf_transit <- spatial_table %>% filter(spatial_category == "outside") %>% + process_convert_table_to_sf( crs = crs, geometry.type = st_multipoint()) + + if (st_crs(shape_table) == NA) { + ct_crs(shape_table) <- crs + } + + shape_table <- st_transform(shape_table, crs = "+proj=longlat +datum=WGS84 +no_defs") + + filtered_sf_inside <- st_transform(filtered_sf_inside, "+proj=longlat +datum=WGS84 +no_defs") + filtered_sf_origin <- st_transform(filtered_sf_origin, "+proj=longlat +datum=WGS84 +no_defs") + filtered_sf_destination <- st_transform(filtered_sf_destination, "+proj=longlat +datum=WGS84 +no_defs") + filtered_sf_transit <- st_transform(filtered_sf_transit, "+proj=longlat +datum=WGS84 +no_defs") + + + #plotting + if (optimized) { + colors <- c("inside" = "green", "origin" = "red", "destination" = "orange", "transit" = "blue") + shapes <- c("Start" = 5, "End" = 3) + plt <- ggplot() + + geom_sf(data = shape_table) + + # geom_sf(data = ) + geom_sf(data = filtered_sf_inside, aes(color = "inside"), size = 3, alpha = 0.5) + + geom_sf(data = filtered_sf_origin, aes(color = "origin"), size = 3, alpha = 0.4) + + geom_sf(data = filtered_sf_destination, aes(color = "destination"), size = 3, alpha = 0.3) + + geom_sf(data = filtered_sf_transit, aes(color = "transit"), size = 2, alpha = 0.1) + + labs(color = "Type") + + scale_colour_manual(values = colors) + plt + return((plt)) + } + + # If we need to adjust design + # css_fix <- "div.info.legend.leaflet-control br {clear: both;}" + # Convert CSS to HTML + # html_fix <- htmltools::tags$style(type = "text/css", css_fix) + + + plt <- leaflet() %>% + addTiles() %>% + addProviderTiles( + "OpenStreetMap", + # give the layer a name + group = "OpenStreetMap" + ) %>% + addProviderTiles( + "Stamen.Toner", + group = "Stamen.Toner" + ) %>% + addProviderTiles( + "Stamen.Terrain", + group = "Stamen.Terrain" + ) %>% + addProviderTiles( + "Esri.WorldStreetMap", + group = "Esri.WorldStreetMap" + ) %>% + addProviderTiles( + "Wikimedia", + group = "Wikimedia" + ) %>% + addProviderTiles( + "CartoDB.Positron", + group = "CartoDB.Positron" + ) %>% + addProviderTiles( + "Esri.WorldImagery", + group = "Esri.WorldImagery" + ) %>% + addPolygons(data = shape_table, opacity = 0.1, color = "green") %>% + addCircleMarkers(filtered_sf_inside, + lng = st_coordinates(filtered_sf_inside$wkt)[seq(1, length(filtered_sf_inside$wkt), 2), 1], + lat = st_coordinates(filtered_sf_inside$wkt)[seq(1, length(filtered_sf_inside$wkt), 2), 2], radius = 3, color = "blue", + label = paste( + "Person_id:", + filtered_sf_inside$person, "
", + "Trip_id:", + filtered_sf_inside$trip_id, "
", + "main_mode:", filtered_sf_inside$main_mode, "
", + "type:", "start", "
", + "Start activity:", + filtered_sf_inside$start_activity_type, "
" + ) %>% lapply(htmltools::HTML) + ) %>% + addCircleMarkers(filtered_sf_inside, + lng = st_coordinates(filtered_sf_inside$wkt)[seq(2, length(filtered_sf_inside$wkt), 2), 1], + lat = st_coordinates(filtered_sf_inside$wkt)[seq(2, length(filtered_sf_inside$wkt), 2), 2], radius = 3, color = "blue", + label = paste( + "Person_id:", + filtered_sf_inside$person, "
", + "Trip_id:", + filtered_sf_inside$trip_id, "
", + "main_mode:", filtered_sf_inside$main_mode, "
", + "type:", "end", "
", + "End activity:", + filtered_sf_inside$end_activity_type, "
" + ) %>% lapply(htmltools::HTML) + ) %>% + addCircleMarkers(filtered_sf_origin, + lng = st_coordinates(filtered_sf_origin$wkt)[seq(1, length(filtered_sf_inside$wkt), 2), 1], + lat = st_coordinates(filtered_sf_origin$wkt)[seq(1, length(filtered_sf_inside$wkt), 2), 2], radius = 2, color = "red", + label = paste( + "Person_id:", + filtered_sf_origin$person, "
", + "Trip_id:", + filtered_sf_origin$trip_id, "
", + "main_mode:", filtered_sf_origin$main_mode, "
", + "type:", "start", "
", + "Start activity:", + filtered_sf_origin$end_activity_type, "
" + ) %>% lapply(htmltools::HTML) + ) %>% + addCircleMarkers(filtered_sf_origin, + lng = st_coordinates(filtered_sf_origin$wkt)[seq(2, length(filtered_sf_inside$wkt), 2), 1], + lat = st_coordinates(filtered_sf_origin$wkt)[seq(2, length(filtered_sf_inside$wkt), 2), 2], radius = 2, color = "red", + label = paste( + "Person_id:", + filtered_sf_origin$person, "
", + "Trip_id:", + filtered_sf_origin$trip_id, "
", + "main_mode:", filtered_sf_origin$main_mode, "
", + "type:", "end", "
", + "End activity:", + filtered_sf_origin$end_activity_type, "
" + ) %>% lapply(htmltools::HTML) + ) %>% + addCircleMarkers(filtered_sf_destination, + lng = st_coordinates(filtered_sf_destination$wkt)[seq(1, length(filtered_sf_inside$wkt), 2), 1], + lat = st_coordinates(filtered_sf_destination$wkt)[seq(1, length(filtered_sf_inside$wkt), 2), 2], radius = 1, color = "orange", + label = paste( + "Person_id:", + filtered_sf_destination$person, "
", + "Trip_id:", + filtered_sf_destination$trip_id, "
", + "main_mode:", filtered_sf_destination$main_mode, "
", + "type:", "start", "
", + "Start activity:", + filtered_sf_destination$end_activity_type, "
" + ) %>% lapply(htmltools::HTML) + ) %>% + addCircleMarkers(filtered_sf_destination, + lng = st_coordinates(filtered_sf_destination$wkt)[seq(2, length(filtered_sf_inside$wkt), 2), 1], + lat = st_coordinates(filtered_sf_destination$wkt)[seq(2, length(filtered_sf_inside$wkt), 2), 2], radius = 1, color = "orange", + label = paste( + "Person_id:", + filtered_sf_destination$person, "
", + "Trip_id:", + filtered_sf_destination$trip_id, "
", + "main_mode:", filtered_sf_destination$main_mode, "
", + "type:", "end", "
", + "End activity:", + filtered_sf_destination$end_activity_type, "
" + ) %>% lapply(htmltools::HTML) + ) %>% + addCircleMarkers(filtered_sf_transit, + lng = st_coordinates(filtered_sf_transit$wkt)[seq(1, length(filtered_sf_inside$wkt), 2), 1], + lat = st_coordinates(filtered_sf_transit$wkt)[seq(1, length(filtered_sf_inside$wkt), 2), 2], radius = 0.15, color = "black", + label = paste( + "Person_id:", + filtered_sf_transit$person, "
", + "Trip_id:", + filtered_sf_transit$trip_id, "
", + "main_mode:", filtered_sf_transit$main_mode, "
", + "type:", "start", "
", + "Start activity:", + filtered_sf_transit$end_activity_type, "
" + ) %>% lapply(htmltools::HTML) + ) %>% + addCircleMarkers(filtered_sf_transit, + lng = st_coordinates(filtered_sf_transit$wkt)[seq(2, length(filtered_sf_inside$wkt), 2), 1], + lat = st_coordinates(filtered_sf_transit$wkt)[seq(2, length(filtered_sf_inside$wkt), 2), 2], radius = 0.15, color = "black", + label = paste( + "Person_id:", + filtered_sf_transit$person, "
", + "Trip_id:", + filtered_sf_transit$trip_id, "
", + "main_mode:", filtered_sf_transit$main_mode, "
", + "type:", "end", "
", + "End activity:", + filtered_sf_transit$end_activity_type, "
" + ) %>% lapply(htmltools::HTML) + ) %>% + addLegend( + colors = c("blue", "red", "orange", "black"), + labels = c( + "Trips inside of region", + "Trips with the end outside region", + "Trips with the start outside region", + "Trips that start and end outside region" + ), + position = "bottomleft", + title = "Type of the point", + opacity = 0.9 + ) %>% + addMiniMap() %>% + addLayersControl( + baseGroups = c( + "OpenStreetMap", "Stamen.Toner", + "Stamen.Terrain", "Esri.WorldStreetMap", + "Wikimedia", "CartoDB.Positron", "Esri.WorldImagery" + ), + # position it on the topleft + position = "topleft" + ) + + plt + return(plt) +} + +#####Processing##### + + +#' Replace Matching Categories of main_mode with United Name in Tibble +#' +#' The process_rename_mainmodes function takes a tibble, trips_table, +#' as input and replaces all occurrences in column main_mode of categories +#' that match a given template with another name provided in united_name. +#' The function provides the flexibility to specify multiple category templates +#' to be united into a single name. +#' +#' @param trips_table tibble of output_trips (from \link{\code{read_output_trips}}) +#' @param unite_modes vector of character strings, +#' changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt) +#' @param united_name character string, specifies the name of the united mode +#' @return tibble with new main_mode representation +#' +#' @export +process_rename_mainmodes<-function(trips_table, + unite_modes = character(0), united_name = "united"){ + + if (length(unite_modes) != 0) { + trips_table$main_mode[grep(paste0(unite_modes, collapse = "|") + , trips_table$main_mode)] <- united_name + } + return(trips_table) +} + + +#' Replace Matching Categories of any column with United Name in Tibble +#' +#' The \code{process_rename_category} function takes a tibble, trips_table, +#' as input and replaces all occurrences of categories +#' that match a given template with another name provided in united_name. +#' The function provides the flexibility to specify multiple category templates +#' to be united into a single name. +#' +#' @param trips_table tible of output_trips (from \link{\code{read_output_trips}}) +#' @param unite_template vector of character string, representing pattern to match categories +#' @param united_name character string, to represent new category for all occurrences matched unite_modes +#' @param column tibble column name, which will be used in occurrences renaming +#' +#' @return modified trips table tibble +#' +#' @export +process_rename_category<-function(trips_table, + unite_template= character(0), united_name = "united",column = "main_mode"){ + + if (length(unite_template) != 0) { + trips_table[[column]][grep(paste0(unite_template, collapse = "|"), trips_table[[column]])] <- united_name + } + return(trips_table) +} + + +#' Calculates main mode distribution +#' +#' The process_get_mainmode_distribution function calculates the distribution of main modes in a given trips_table.\cr +#' It provides insights into the frequency or percentage of each main mode within the dataset. +#' +#' By default, the function counts the occurrences of each main mode in the trips_table tibble and returns the counts for each unique main mode. \cr +#' Alternatively, when the percentage parameter is set to TRUE, the function normalizes the counts to represent the percentage distribution of each main mode within the dataset. +#' +#' @param trips_table tible of output_trips (from \link{read_output_trips}) +#' @param percentage boolean, by default FALSE, sets if output should be given in percentage +#' +#' @return tibble that provides the distribution of main modes in the input trips_table. +#' +#' @export +process_get_mainmode_distribution<-function(trips_table,percentage = FALSE){ + + trips_table_count <- trips_table %>% + count(main_mode) + if(percentage){ + trips_table_count<- trips_table_count %>% mutate(n = n / sum(n) * 100) + } + + return(trips_table_count) +} + + +#' Get Travel Distance Distribution by Main Mode +#' +#' The \code{process_get_travdistance_distribution} function calculates the distribution of travel distances based on main modes in a given trips_table tibble. It provides insights into the average distance traveled for each main mode. +#' +#' @param trips_table A tibble of output_trips (from \link{\code{read_output_trips}}) +#' @param euclidean Logical value indicating whether to calculate the average as euclidean distance or as travel distance. Default is FALSE, which calculates the average traveled distance. +#' +#' @return A tibble containing the main_mode column representing unique main modes and the avg_dist column representing the average travel distance for each main mode. +#' +#' @export +process_get_travdistance_distribution<-function(trips_table,euclidean = FALSE){ + + trips_table = trips_table %>% + group_by(main_mode) %>% + summarize(avg_dist = if_else(euclidean,mean(euclidean_distance),mean(traveled_distance))) + + return(trips_table) +} + + +#' Get Travel and Wait Time by Main Mode +#' +#' The \code{process_get_travelwaittime_by_mainmode} function calculates the average travel time and average wait time for each main mode in a given trips_table tibble. +#' +#' @param trips_table A tibble of output_trips (from \link{\code{read_output_trips}}) +#' @param time_format A character string indicating the desired time format for the output. The options are "minute", "hour", or "second". The default is "minute". +#' +#' @return A tibble containing the main_mode column representing unique main modes, trav_time_avg column representing the average travel time for each main mode, and wait_time_avg column representing the average wait time for each main mode. +#' +#' @export +process_get_travelwaittime_by_mainmode<-function(trips_table, + time_format = "minute"){#also could be hours/seconds + + #get 2 columns with mean travel time and mean wait time grouped by main_mode in seconds + + trips_table <-trips_table %>% + process_convert_time(time_format = time_format, time_column = "trav_time") %>% + process_convert_time(time_format = time_format, time_column = "wait_time") + + avg_time = trips_table %>% group_by(main_mode)%>% + summarize(trav_time_avg = mean(trav_time), + wait_time_avg = mean(wait_time)) + + return(avg_time) +} + + +#' Adds additional \strong{dist_cat} column based on the \strong{distances_array} parameter +#' +#' Categorizes each trip into a distance bin based on traveled distance. +#' E.g. distance traveled is 1500, distances array is (1000,2000), then the category is "1000-2000". +#' +#' @param trips_table tibble of output_trips (from \link{read_output_trips}) +#' @param distances_array numeric vector, represents segments for distance categories ordered (in meters), +#' standard value: c(1000,2000,5000,10000,20000,50000,100000) +#' +#' @return trips table with added the added column dist_cat +#' @export +process_append_distcat <- function(trips_table,distances_array = c(1000,2000,5000,10000,20000,50000,100000)){ + + distances_array = sort(c(distances_array,c(0,Inf))) + modes = levels(factor(trips_table$main_mode)) + + #Also filtering table into a new doesn't creates new objects in memory, so it works fast + #Upd: it creates copy of dataframe on each mutate :/ + + result_table <- c(NULL) + + str_factors<-c(NULL) + for(i in 1:(length(distances_array)-1)){ + part_table <- trips_table %>% + filter(traveled_distance>=distances_array[i] & traveled_distance% + mutate(dist_cat = paste0(distances_array[i],"-",distances_array[i+1])) + str_factors<- c(str_factors,paste0(distances_array[i],"-",distances_array[i+1])) + result_table <- rbind(result_table,part_table) + } + + result_table$dist_cat = factor(result_table$dist_cat,levels = str_factors) + return(result_table) +} + +#' Converts time column specified in \strong{time_column} to numeric representation of minutes, hours or seconds +#' +#' Default output_trips table time columns(\strong{dep_time}, \strong{trav_time}, \strong{wait_time}) are in 'hms' format. +#' To convert this type to numeric, specify \strong{time_column} to be converted, +#' and the unit \strong{time_format}. Acceptable units are "hour", "minute" and "second". +#' +#' @param trips_table tibble of output_trips (from \link{read_output_trips}) +#' +#' @param time_format char, defines time unit to be used ("hour", "minute", "second") +#' +#' @param time_column char, name of the column from table to be converted (\strong{dep_time}, \strong{trav_time}, \strong{wait_time}) +#' +#' @return tibble, containing column with specified time_format +#' +#' @export +process_convert_time <- function(trips_table,time_format = "hour",time_column = "dep_time"){ + + #get 2 columns with mean travel time and mean wait time grouped by main_mode in seconds + trips_table[[time_column]] = as.numeric(hms::hms(seconds_to_period(trips_table[[time_column]]))) + + if(time_format == "minute"){ + #convert seconds to minutes + trips_table[[time_column]] = trips_table[[time_column]]/60 + return(trips_table) + }else if(time_format == "hour"){ + trips_table[[time_column]] = trips_table[[time_column]]/3600 + return(trips_table) + }else if(time_format == "second"){ + return(trips_table) + } + + warning("time_format is unknown returned time is in seconds. Otherwise try minute, hour, second") + return(trips_table) +} + +######Spatial###### + + +#' Filters trips_table(from ,\link{read_output_trips}) depending by location using a shapefile +#' +#' Uses output_trips and an sf object (can be created using the function st_read()), +#' transforms both objects to match a mutual coordinate system (crs) +#' and filters the trips from output_trips depending on their spatial type:\cr +#' if spatial_type="inside" returns a table that contains trips inside given shape\cr +#' if spatial_type="originating" returns a table that contains trips which start inside the shape and end outside of the shape\cr +#' if spatial_type="destinating" returns a table that contains trips which end inside shape and start outside of the shape\cr +#' if spatial_type="outside" returns a table that contains trips which start and end outside of the given shape +#' +#' @param trips_table tibble of trips_output (from \link{read_output_trips}) +#' +#' @param shape_Table sf object(data frame with geometries), can be created using st_read() +#' @param crs numeric representation of the EPSG code or proj4string for the corresponding coordinate system +#' of the trip coordinates, can be found in network file from output directory of MATSim simulation +#' @param spatial_type bool, defines trips to conclude (see description) +#' +#' @return tibble, with filtered trips depending on shapeTable and spatial types (see description) +#' +#' @export +process_filter_by_shape <- function(trips_table, + shape_table, + crs, + spatial_type = "inside") { + + start.inshape <- TRUE + end.inshape <- TRUE + + if(spatial_type == "inside"){ + start.inshape <- TRUE + end.inshape <- TRUE + }else if(spatial_type == "outside"){ + start.inshape <- FALSE + end.inshape <- FALSE + }else if(spatial_type == "originating"){ + start.inshape <- TRUE + end.inshape <- FALSE + }else if(spatial_type == "destinating"){ + start.inshape <- FALSE + end.inshape <- TRUE + }else{ + stop("There are only 4 possible spatial_types: inside, outside, originating, destinating") + } + # shape_table <- st_read(shapeFile) + if (st_crs(shape_table) == NA) { + st_crs(shape_table) <- crs + } + + sf_table <- process_convert_table_to_sf(trips_table, crs = crs, geometry.type = st_point()) + shape_table <- st_transform(shape_table, crs = crs) + # shape_table isn't table - shape + + union_shape <- st_union(shape_table) # transforms the crs back to the previous in the file + union_shape <- st_transform(union_shape, crs = st_crs(shape_table)) + + + st_geometry(sf_table) <- "start_wkt" # Set start_wkt as an active geometry + cont1 <- st_contains(union_shape, sf_table)[[1]] # Indexes of rows where start point is in shapefile + + st_geometry(sf_table) <- "end_wkt" # Set end_wkt as and active geometry + cont2 <- st_contains(union_shape, sf_table)[[1]] # Indexes of rows where end point is in shapefile + + # get trips that ended outside of shape + cont_end_outside <- setdiff(1:nrow(sf_table), cont2) + + # get trips that started outside of shape + cont_start_outside <- setdiff(1:nrow(sf_table), cont1) + + if (start.inshape == TRUE && end.inshape == TRUE) { + cont_union <- intersect(cont1, cont2) + } else if (start.inshape == TRUE && end.inshape == FALSE) { + cont_union <- intersect(cont1, cont_end_outside) + } else if (start.inshape == FALSE && end.inshape == TRUE) { + cont_union <- intersect(cont2, cont_start_outside) + } else { + cont_union <- intersect(cont_start_outside, cont_end_outside) # Give back trips that are neither starting and ending outside the area + } + + + return(trips_table[cont_union, ]) +} + + +#' Appends an additional column with the trip type to output_trips +#' +#' Using a shape_file of the project area an additional column is created, categorizing all trips into the following categories. +#' inside: trips that start and end inside the given shape +#' originating: trips that start inside the shape and end outside of the shape +#' destinating: trips that end inside the shape and start outside of the shape +#' outside: trips that start and end outside of the shape +#' +#' Please be aware that this \link{process_filter_by_shape} currently only works, when one geometry is loaded.) +#' +#' @param trips_table tibble of output_trips (from read_output_trips()) +#' +#' @param shape_Table sf object(data frame with geometries), can be created using st_read(), is used to categorize the trips. +#' @param crs numeric representation of the EPSG code or proj4string for the corresponding coordinate system +#' of the trip coordinates, can be found in network file from output directory of MATSim simulation +#' +#' @return tibble, with additional column containing the trip type +#' +#' @export +process_append_spatialcat <- function(trips_table, + shape_table, + crs) { + + start.inshape <- TRUE + end.inshape <- TRUE + + # shape_table <- st_read(shapeFile) + if (st_crs(shape_table) == NA) { + st_crs(shape_table) <- crs + } + + sf_table <- process_convert_table_to_sf(trips_table, crs = crs, geometry.type = st_point()) + shape_table <- st_transform(shape_table, crs = crs) + # shape_table isn't table - shape + + union_shape <- st_union(shape_table) # transforms the crs back to the previous in the file + union_shape <- st_transform(union_shape, crs = st_crs(shape_table)) + + + st_geometry(sf_table) <- "start_wkt" # Set start_wkt as an active geometry + cont1 <- st_contains(union_shape, sf_table)[[1]] # Indexes of rows where start point is in shapefile + + st_geometry(sf_table) <- "end_wkt" # Set end_wkt as and active geometry + cont2 <- st_contains(union_shape, sf_table)[[1]] # Indexes of rows where end point is in shapefile + + # get trips that ended outside of shape + cont_end_outside <- setdiff(1:nrow(sf_table), cont2) + + # get trips that started outside of shape + cont_start_outside <- setdiff(1:nrow(sf_table), cont1) + + cont_union_inside <- intersect(cont1,cont2) + cont_union_outside <- intersect(cont_start_outside,cont_end_outside) + cont_union_originating <- intersect(cont1,cont_end_outside) + cont_union_destinating <- intersect(cont2, cont_start_outside) + + trips_table$spatial_category = NA + + trips_table[cont_union_inside, ]$spatial_category <- "inside" + trips_table[cont_union_outside, ]$spatial_category <- "outside" + trips_table[cont_union_originating, ]$spatial_category <- "originating" + trips_table[cont_union_destinating, ]$spatial_category <- "destinating" + + + return(trips_table) +} + +#' Reads the coordinate reference system from a MATSim output directory (output_config.xml) +#' +#' @param config_path specifies path to configuration file +#' +#' +#' @return EPSG code of coordinate reference system +#' +#' @export +process_get_crs_from_config <- function(config_path) { + + if (grepl("output_config.xml$", config_path) == TRUE) + { + config <- read_xml(folder) + + param_nodes = xml_find_all(config,"//param") + + coord_node = param_nodes[xml_attr(param_nodes,"name") == "coordinateSystem"] + + coord_system = xml_attr(coord_node,"value") + return(coord_system) + } + + files <- list.files(config_path, full.names = TRUE) + # Read from global/local directory + # output_config.xml is contained as output_trips.csv.gz + if (length(grep("output_config.xml$", files)) != 0) { + config <- read_xml(files[grep("output_config.xml$", files)]) + + param_nodes = xml_find_all(config,"//param") + + coord_node = param_nodes[xml_attr(param_nodes,"name") == "coordinateSystem"] + + coord_system = xml_attr(coord_node,"value") + return(coord_system) + } + return(NA) +} + +#' Creates an origin/destination matrix either in conventional form (row names = origin, column names = destination) +#' or for simwrapper (origin and destination as columns) +#' +#' +#' @param trips_table tibble of trips_output (from \link{read_output_trips}) +#' +#' @param shape_path string, full path to the shapefile (.shp) (shape files are made up of several files with the same name and the folder also needs to include a .dbf file) +#' +#' @param crs numeric, coordinate system in the form of the EPSG code or proj4string, can be found in the MATSim network file +#' +#' @param dump.output.to string, path to a folder to save the .csv file +#' +#' @param colnames string, column names can be specified (i.e. to fit the shape file), if not they are numbered +#' +#' @param simwrapper boolean, creates output in the format used for simwrapper if the path for the shapefile is specified +#' +#' @param outer boolean, determines if flows outside of the shapefile are used, standard value is FALSE +#' +#' @return tibble of origin/destination matrix +#' +#' @export +process_get_od_matrix<- function(trips_table, + shape_path, + crs, + dump.output.to = matsimDumpOutputDirectory, + simwrapper = FALSE, + colnames = "numeric", + outer = FALSE){ + + defaultW <- getOption("warn") + options(warn = -1) + + #if tripstable given as folder/file + if(sum(class(trips_table) %in% c("tbl_df","tbl","data.frame"))<1){ + tripsTable <- read_output_trips(trips_table) + } + + sfTable <- transformToSf(trips_table,crs,geometry.type = st_point()) + + shape = st_read(shape_path) + + if (st_crs(shape) == NA) { + st_crs(shape) <- crs + } + shape = st_transform(shape,crs = crs) + + sf_table <- transformToSf(trips_table, crs = crs, geometry.type = st_point()) + + sf_start = sfTable %>% select(trip_id,start_wkt) + st_geometry(sfTable) = "end_wkt" + sf_end = sfTable %>% select(trip_id,end_wkt) + + #Get all inner intersects + sf_intersect_start = st_contains(shape,sf_start) + sf_intersect_end = st_contains(shape,sf_end) + + + if(outer == TRUE){ + #Get all outer intersects + joined_shape = st_union(shape) + + start_inside = st_contains(joined_shape,sf_start) + end_inside = st_contains(joined_shape,sf_end) + + start_outside = 1:nrow(sf_start) + end_outside = 1:nrow(sf_end) + + start_outside = start_outside[! start_outside %in% start_inside[[1]]] + + end_outside = end_outside[! end_outside %in% end_inside[[1]]] + + sf_intersect_start = append(sf_intersect_start,list(start_outside)) + sf_intersect_end = append(sf_intersect_end,list(end_outside)) + } + + # Create matrix out of it + result_tibble = as_tibble(data.frame(matrix(nrow=0,ncol=nrow(shape)))) + colnames(result_tibble) = 1:nrow(shape) + + for(i in 1:length(sf_intersect_start)){ + temp = c() + for(j in 1:length(sf_intersect_start)){ + start_i = sf_intersect_start[[i]] + end_j = sf_intersect_end[[j]] + + number_of_trips = length(intersect(start_i,end_j)) + + temp = append(temp,number_of_trips) + + } + result_tibble = rbind(result_tibble,temp) + } + + if(colnames!="numeric" & colnames %in% colnames(shape)){ + colnames(result_tibble) = shape[[colnames]] + if(outer == TRUE){ + rownames(result_tibble) = c(shape[[colnames]],"outer") + colnames(result_tibble)[length(colnames(result_tibble))] = "outer" + }else{ + rownames(result_tibble) = shape[[colnames]] + } + + }else{ + colnames(result_tibble) = sapply(1:length(sf_intersect_start),as.character) + rownames(result_tibble) = sapply(1:length(sf_intersect_start),as.character) + } + + + result_melt = melt(as.matrix(result_tibble)) + colnames(result_melt) = c("origin","destination",1) + + options(warn = defaultW) + return(result_tibble) +} + + + +#' Transforms the data frame trips_output (from \link{read_output_trips}) from tibble to sf (table with geometry features) +#' +#' Transforms the data frame trips_output (from \link{read_output_trips}) into an sf object using start_x, end_x, start_y, end_y as geometry features.\cr +#' If geometry.type = st_multipoint() or geometry.type = st_linestring() it adds one geometry column (wkt format),\cr +#' if geometry.type = st_point() it adds the geometry columns start_wkt and end_wkt.\cr +#' Added column/columns are projected to given CRS (coordinate reference system).\cr +#' The columns start_x, end_x, start_y, end_y are deleted from the resulting data frame. +#' +#' @param table tibble trips_output (from \link{read_output_trips}) +#' +#' @param crs numeric, coordinate system in the form of the EPSG code or proj4string, can be found in the MATSim network file +#' +#' @param geometry.type type of sf transformation, default is st_multipoint(), geometry.type can be:\cr +#' !!!st_point()- resulting table contains two geometry columns: start_wkt and end_wkt, representing start and end points as POINTS!!! or\cr +#' !!!st_multipoint()- resulting table contains one geometry column, representing start and end points as MULTIPOINT!!! or\cr +#' !!!st_linestring() - resulting table contains one geometry column, representing the line between start and end points as LINESTRING!!!\cr +#' +#' @return sf object (data frame with geometries depending on geometry.type) +#' +#' @export +process_convert_table_to_sf <- function(table, + crs, + geometry.type = st_multipoint()) { + if (class(geometry.type)[2] == "POINT") { + table1 <- table %>% + # mutate(wkt = paste("MULTIPOINT(", start_x, " ", start_y, ",", end_x, " ", end_y, ")", sep ="")) + mutate(start_wkt = paste("POINT(", start_x, " ", start_y, ")", sep = "")) + table2 <- table %>% + mutate(end_wkt = paste("POINT(", end_x, " ", end_y, ")", sep = "")) + attr(table, "geometry.type") <- "POINT" + + + table1_wkt <- st_as_sf(table1, wkt = "start_wkt") %>% select(-start_x, -start_y, -end_x, -end_y) + table2_wkt <- st_as_sf(table2, wkt = "end_wkt") %>% select(-start_x, -start_y, -end_x, -end_y) + + + result_table <- table1_wkt %>% mutate(end_wkt = table2_wkt$end_wkt) + st_geometry(result_table) <- "start_wkt" + st_crs(result_table) <- crs + st_geometry(result_table) <- "end_wkt" + st_crs(result_table) <- crs + st_geometry(result_table) <- "start_wkt" + return(result_table) + } else if (class(geometry.type)[2] == "MULTIPOINT") { + table <- table %>% + mutate(wkt = paste("MULTIPOINT(", start_x, " ", start_y, ",", end_x, " ", end_y, ")", sep = "")) + attr(table, "geometry.type") <- "MULTIPOINT" + + + result_table <- st_as_sf(table, wkt = "wkt") %>% select(-start_x, -start_y, -end_x, -end_y) + + st_crs(result_table) <- crs + return(result_table) + } else if (class(geometry.type)[2] == "LINESTRING") { + table <- table %>% + mutate(wkt = paste("LINESTRING(", start_x, " ", start_y, ",", end_x, " ", end_y, ")", sep = "")) + attr(table, "geometry.type") <- "LINESTRING" + + + result_table <- st_as_sf(table, wkt = "wkt") %>% select(-start_x, -start_y, -end_x, -end_y) + + st_crs(result_table) <- crs + return(result_table) + } else { + return(NA) + } +} + + +#####Helping functions#### diff --git a/R/personsOutput.R b/R/personsOutput.R deleted file mode 100644 index c9b9e40..0000000 --- a/R/personsOutput.R +++ /dev/null @@ -1,90 +0,0 @@ -matsimDumpOutputDirectory <- "./matsim_r_output" -dashboard_file <- "/dashboard-1-trips.yaml" - - -#' Load MATSim output_persons table into memory -#' -#' 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 -#' -#' @param input_path is a character string, path to the local MATSim output directory, to the persons csv directly, or a http link to the file. -#' @param n_max integer, maximum number of lines to read within output_persons - -#' @return tibble of output_persons -#' -#' @export -readPersonsTable <- function(input_path = ".", n_max = Inf) { - options(digits = 18) - - persons_file <- "" - - if(dir.exists(input_path)){ - files <- list.files(input_path, full.names = TRUE) - person_file_indicies <- grep("output_persons.csv.gz$", files) - - if(length(person_file_indicies) == 1){ - persons_file <- files[person_file_indicies] - } else { - stop('There is supposed to be a single "output_persons.csv.gz" found in directory') - } - } else { - persons_file <- input_path - } - - persons_output_table <- read_delim(persons_file, - delim = ";", - locale = locale(decimal_mark = "."), - n_max = n_max, - col_types = cols( - executed_score = col_character(), - first_act_x = col_character(), - first_act_y = col_character(), - first_act_type = col_character(), - ) - ) - - persons_output_table <- persons_output_table %>% - mutate( - executed_score = as.double(executed_score), - first_act_x = as.double(first_act_x), - first_act_y = as.double(first_act_y), - ) - - attr(persons_output_table,"table_name") <- input_path - - return(persons_output_table) -} - -#' @param personTibble_base persons tibble of the base case, can be loaded with readPersonsTable. -#' @param personTibble_policy persons tibble of the policy case, can be loaded with readPersonsTable. -#' -#' @return ggplot boxplot of the distribution of the score differences -#' -#' @export -boxplotScoreDifferences <- function(personTibble_base, personTibble_policy){ - joined <- inner_join(personTibble_base, personTibble_policy, by = "person", suffix = c("_base", "_policy")) %>% - select(person, - executed_score_base, - executed_score_policy) %>% - mutate(score_diff = executed_score_policy - executed_score_base) - - result <- ggplot(joined, aes(y = score_diff)) + - geom_boxplot(fill = "#0099f8") + - labs( - title = "Distribution of score differences", - subtitle = "score_delta = score(policy) - score(base)", - #caption = "Source: MTCars dataset", - y = "score_delta" - ) + - theme_classic() + - theme( - plot.title = element_text(color = "#0099f8", size = 16, face = "bold", hjust = 0.5), - plot.subtitle = element_text(face = "bold.italic", hjust = 0.5), - plot.caption = element_text(face = "italic"), - axis.ticks.x = element_blank(), - axis.title.x = element_blank(), - axis.text.x = element_blank() - ) - result -} diff --git a/R/simwrapper.R b/R/simwrapper.R index f128bda..08321d1 100644 --- a/R/simwrapper.R +++ b/R/simwrapper.R @@ -1,12 +1,12 @@ -#' Creates dashboard for the given table or folder with data -#' + +#' Creates dashboard for the given table with data #' #' #' @param table trips_output tibble from readTripsTable() #' -#' @param append specifies if the ouput folder should be erased before creating +#' @param append specifies if the ouput folder should be erased before creating, default = FALSE #' -#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard and all plots using functions: +#' @param dump.output.to output folder, yaml files and plots from the following functions are saved there: #' plotModalSplitBarChart(),plotModalSplitPieChart(),plotModalShift(). #' #' @return generates folder with content for simwrapper out of trips table @@ -32,17 +32,17 @@ prepareSimwrapperDashboardFromTable <- function(table, dump.output.to = matsimDu -#' Creates dashboard for the given table or folder with data +#' Creates dashboard for the given folder with data #' #' #' -#' @param folder specifies data source folder with tripsOutput +#' @param folder file path, specifies data source folder that includes a output_trips.csv file #' -#' @param append specifies if the ouput folder should be erased before creating +#' @param append specifies if the ouput folder should be erased before creating, default = FALSE #' -#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard and all plots +#' @param dump.output.to output folder, yaml files are saved there #' -#' @return tibble of output_trips from folder. Generates content needed for Simwrapper +#' @return tibble of output_trips from folder and content needed for Simwrapper #' #' @export prepareSimwrapperDashboardFromFolder <- function(folder,dump.output.to = matsimDumpOutputDirectory, append = FALSE) { @@ -59,11 +59,11 @@ prepareSimwrapperDashboardFromFolder <- function(folder,dump.output.to = matsimD #' Creates/adds XY hexagon definition of output trips to a summary dashboard #' -#' @param pathToOutputTrips specifies path to a data source of output_trips +#' @param pathToOutputTrips file path to output_trips.csv file #' -#' @param crs specifies an coordinate reference system of output_trips +#' @param crs specifies the coordinate reference system of output_trips #' -#' @param dump.output.to path to an folder with dashboard +#' @param dump.output.to path to a folder with simwrapper dashboard #' #' @return changed file #' @@ -127,7 +127,7 @@ clearDashboard<- function(matsimOutputFolder){ -#' Creates comparison dashboard for the 2 given tables or folder with data +#' Creates comparison dashboard for the two given tables or folders with data #' #' #' @@ -135,12 +135,12 @@ clearDashboard<- function(matsimOutputFolder){ #' #' @param table2 trips_output tibble from readTripsTable() #' -#' @param append specifies if the ouput folder should be erased before creating +#' @param append specifies if the output folder should be erased before creating, default = FALSE #' -#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard and all plots using functions: +#' @param dump.output.to output folder, yaml files and plots from the following functions are saved there: #' plotModalSplitBarChart(),plotModalSplitPieChart(),plotModalShift(). #' -#' @return generates folder with content for simwrapper out of trips table +#' @return generates folder with content for simwrapper from a trips table #' #' @export prepareComparisonSimwrapperDashboardFromTable <- function(table1,table2, dump.output.to = matsimDumpOutputDirectory, append = FALSE) { diff --git a/R/tripsOutput.R b/R/tripsOutput.R deleted file mode 100644 index a17d285..0000000 --- a/R/tripsOutput.R +++ /dev/null @@ -1,2586 +0,0 @@ -matsimDumpOutputDirectory <- "./matsim_r_output" -dashboard_file <- "/dashboard-1-trips.yaml" - -#' Load MATSIM output_trips table into Memory -#' -#' Loads a MATSim CSV output_trips from file or archive, -#' creating a tibble with columns as in csv file -#' -#' @param input_path character string, path to matsim output directory or http link to the file. -#' @param n_max integer, maximum number of lines to read within output_trips -#' @return tibble of trips_output -#' -#' @export -readTripsTable <- function(input_path = ".", n_max = Inf) { - options(digits = 18) - trips_file <- "" - - # if input_path is a directory, find the correct file path within it - if(dir.exists(input_path)){ - files <- list.files(input_path, full.names = TRUE) - trip_file_indicies <- grep("output_trips.csv.gz$", files) - - if(length(trip_file_indicies) == 1){ - trips_file <- files[trip_file_indicies] - } else { - stop('There is supposed to be a single "output_trips.csv.gz" found in directory') - } - } else { - trips_file <- input_path - } - - trips_output_table <- read_delim(trips_file, - delim = ";", - locale = locale(decimal_mark = "."), - n_max = n_max, - col_types = cols( - start_x = col_character(), - start_y = col_character(), - end_x = col_character(), - end_y = col_character(), - end_link = col_character(), - start_link = col_character() - ) - ) - # person is mostly integer, but contains also chars(see Hamburg 110813 observation) - # doesn't reads coordinates correctly - trips_output_table <- trips_output_table %>% - mutate( - start_x = as.double(start_x), - start_y = as.double(start_y), - end_x = as.double(end_x), - end_y = as.double(end_y) - ) - attr(trips_output_table,"table_name") <- trips_file - return(trips_output_table) - -} - -#' Plot main_mode distribution as a Pie Chart -#' -#' Takes Table trips_output (from readTripsTable()), -#' to plot pie chart with with values that represent -#' percentage of using transport modes from trips -#' -#' Function automatically detects transport_modes from table -#' and plots pie chart. -#' Using parameters unite.columns, specific columns could be given, to unite them in 1 mode with the name united.name(by default 'united') -#' -#' -#' @param tripsTable tible of trips_output (from readTripsTable()) -#' @param 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 -#' @param united.name character string, if columns were united, you can specify name for the resulting column in chart -#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored -#' @param only.files boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly -#' -#' @return Pie Chart plot of transport mode distribution, values given in percents -#' -#' @export -plotModalSplitPieChart <- function(tripsTable, unite.columns = character(0), united.name = "united", dump.output.to = matsimDumpOutputDirectory, - only.files = FALSE) { - - # If some columns should be united - if (length(unite.columns) != 0) { - tripsTable$main_mode[grep(paste0(unite.columns, collapse = "|"), tripsTable$main_mode)] <- united.name - } - - # tripsTableCount gives percentage representation out - tripsTableCount <- tripsTable %>% - count(main_mode) %>% - mutate(n = n / sum(n) * 100) - - # getthe positions - positions <- tripsTableCount %>% - mutate( - csum = rev(cumsum(rev(n))), - pos = n / 2 + lead(csum, 1), - pos = if_else(is.na(pos), n / 2, pos) - ) - - # plotting - - plt <- ggplot(tripsTableCount, aes(x = "", y = n, fill = main_mode)) + - geom_bar(stat = "identity", width = 1) + - coord_polar("y", start = 0) + - geom_label_repel( - data = positions, - aes(y = pos, label = paste0(round(n, digits = 1), "%")), - size = 4.5, nudge_x = 1, show.legend = FALSE - ) + - ggtitle("Distribution of transport type") + - theme_void() - plt - if (file.exists(dump.output.to)) { - ggsave(paste0(dump.output.to, "/modalSplitPieChart.png"),width = 6,height = 10, plt) - } else { - dir.create(dump.output.to) - ggsave(paste0(dump.output.to, "/modalSplitPieChart.png"),width = 6,height = 10, plt) - } - - # Generating yaml and output_files - if (file.exists(dump.output.to)) { - write_file(paste(tripsTableCount$main_mode, collapse = "\t"), paste0(dump.output.to, "/modalSplitPieChart.txt"), append = FALSE) - write_file(paste("\r\n", paste(tripsTableCount$n, collapse = "\t")), paste0(dump.output.to, "/modalSplitPieChart.txt"), append = TRUE) - # write.csv2(tripsTableCount,paste0(matsimDumpOutputDirectory,"/modalSplitPieChart.csv")) - } else { - dir.create(dump.output.to) - write_file(paste(tripsTableCount$main_mode, collapse = "\t"), paste0(dump.output.to, "/modalSplitPieChart.txt"), append = FALSE) - write_file(paste("\r\n", paste(tripsTableCount$n, collapse = "\t")), paste0(dump.output.to, "/modalSplitPieChart.txt"), append = TRUE) - # write.csv2(tripsTableCount,paste0(matsimDumpOutputDirectory,"/modalSplitPieChart.csv")) - } - - yaml_list <- list( - header = list(tab = "Summary", title = "Dashboard", description = "Plots from output directory"), - layout = list("1" = list( - title = paste0("Modal Split Pie Chart from",attr(tripsTable,"table_name")), - description = "generated by plotModalSplitPieChart()", - type = "pie", - width = 1, - props = list(dataset = "modalSplitPieChart.txt", useLastRow = "true") - )) - ) - - if (file.exists(paste0(dump.output.to, dashboard_file))) { - yaml_from_directory <- read_yaml(paste0(dump.output.to, dashboard_file)) - yaml_from_directory$layout <- append(yaml_from_directory$layout, list(new_row = list( - title = paste0("Modal Split Pie Chart from",attr(tripsTable,"table_name")), - description = "generated by plotModalSplitPieChart()", - type = "pie", - width = 1, - props = list(dataset = "modalSplitPieChart.txt", useLastRow = "true") - ))) - names(yaml_from_directory$layout) <- 1:length(names(yaml_from_directory$layout)) - - write_yaml(yaml_from_directory, paste0(dump.output.to, dashboard_file)) - } else { - write_yaml(yaml_list, paste0(dump.output.to, dashboard_file)) - } - if(!only.files){ - return(plt) - } - -} - -#' Plot main_mode distribution as a bar Chart -#' -#' Takes Table trips_output (from readTripsTable()), -#' to plot bar chart with with values that represent -#' percentage of using transport modes from trips -#' -#' Function automatically detects transport_modes from table -#' and plots pie chart with percentage of distribution. -#' Using parameters unite.columns, specific columns could be given, to unite them in 1 mode with the name united.name(by default 'united') -#' -#' -#' @param tripsTable tible of trips_output (from readTripsTable()) -#' @param 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 -#' @param united.name character string, if columns were united, you can specify name for the resulting column in chart -#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored -#' @param only.files boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly -#' -#' @return Bar Chart plot of transport mode distribution, values given in percents -#' -#' @export -plotModalSplitBarChart <- function(tripsTable, unite.columns = character(0), united.name = "united",dump.output.to = matsimDumpOutputDirectory, - only.files = FALSE) { - - # If some columns should be united - if (length(unite.columns) != 0) { - tripsTable$main_mode[grep(paste0(unite.columns, collapse = "|"), tripsTable$main_mode)] <- united.name - } - # Get percentage - tripsTableCount <- tripsTable %>% - count(main_mode) %>% - arrange(desc(n)) - text_for_y = tripsTableCount$n - - - fig = plot_ly(data = tripsTableCount,x = ~main_mode,y = ~n,type = "bar", - text = text_for_y, - textposition = "auto", - name = "Distribution of transport type") - fig = fig %>% layout(yaxis = list(title = "Count"),barmode = "group") - - if (file.exists(dump.output.to)) { - #ggsave(paste0(dump.output.to, "/modalSplitBarChart.png"),width = 6,height = 10, fig) - htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/modalSplitBarChart.html")) - } else { - dir.create(dump.output.to) - htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/modalSplitBarChart.html")) - #ggsave(paste0(dump.output.to, "/modalSplitBarChart.png"),width = 6,height = 10, fig) - } - - # Generating yaml and output_files - if (file.exists(dump.output.to)) { - write.table(tripsTableCount,paste0(dump.output.to,"/modalSplitBarChart.csv"),row.names = FALSE,sep = ",") - } else { - dir.create(dump.output.to) - #write_file(paste(tripsTableCount$main_mode, collapse = "\t"), paste0(dump.output.to, "/modalSplitBarChart.txt"), append = FALSE) - #write_file(paste("\r\n", paste(tripsTableCount$n, collapse = "\t")), paste0(dump.output.to, "/modalSplitBarChart.txt"), append = TRUE) - write.table(tripsTableCount,paste0(dump.output.to,"/modalSplitBarChart.csv"),row.names = FALSE,sep = ",") - } - - yaml_list <- list( - header = list(tab = "Summary", title = "Dashboard", description = "Plots from output directory"), - layout = list("1" = list( - title = paste0("Modal Split Bar Chart from ",attr(tripsTable,"table_name")), - description = "generated by plotModalSplitBarChart()", - type = "bar", - width = 1, - props = list(dataset = "modalSplitBarChart.csv", - x = "main_mode", - y = "n", - yAxisTitle = "Count of trips", - xAxisTitle = "Main mode of trip") - )) - ) - - if (file.exists(paste0(dump.output.to, dashboard_file))) { - yaml_from_directory <- read_yaml(paste0(dump.output.to, dashboard_file)) - yaml_from_directory$layout <- append(yaml_from_directory$layout, list(new_row = list( - title = paste0("Modal Split Bar Chart from ",attr(tripsTable,"table_name")), - description = "generated by plotModalSplitBarChart()", - type = "bar", - width = 1, - props = list(dataset = "modalSplitBarChart.csv", - x = "main_mode", - y = "n", - yAxisTitle = "Count of trips", - xAxisTitle = "Main mode of trip") - ))) - names(yaml_from_directory$layout) <- 1:length(names(yaml_from_directory$layout)) - - write_yaml(yaml_from_directory, paste0(dump.output.to, dashboard_file)) - } else { - write_yaml(yaml_list, paste0(dump.output.to, dashboard_file)) - } - # plotting - if(!only.files){ - - fig - return(fig) - } -} - -#' Bar Chart with main_mode on x-axis and average travel/wait time on y-axis -#' -#' Takes Table trips_output (from readTripsTable()), -#' 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') -#' -#' -#' @param tripsTable tible of trips_output (from readTripsTable()) -#' @param 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 -#' @param united.name character string, if columns were united, you can specify name for the resulting column in chart -#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored -#' @param only.files boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly -#' -#' @return Bar Chart plot of average time spent on travel/wait -#' -#' @export -plotAverageTravelWait <- function(tripsTable, unite.columns = character(0), united.name = "united",dump.output.to = matsimDumpOutputDirectory, - only.files = FALSE) { - - # If some columns should be united - if (length(unite.columns) != 0) { - tripsTable$main_mode[grep(paste0(unite.columns, collapse = "|"), tripsTable$main_mode)] <- united.name - } - - avg_time = tripsTable %>% group_by(main_mode)%>% - summarize(trav_time_avg = hms::hms(seconds_to_period(mean(trav_time))), - wait_time_avg = hms::hms(seconds_to_period(mean(wait_time)))) %>% - mutate(trav_time_avg = minute(trav_time_avg),wait_time_avg = minute(wait_time_avg)) - - - fig = plot_ly(data = avg_time,x = ~main_mode,y = ~trav_time_avg,type = 'bar',name = "AVG Time Travelling") - fig = fig %>% add_trace(y = ~wait_time_avg,name = "AVG Time Waiting") - fig = fig %>% layout(yaxis = list(title = "Time spent (in minutes)"),barmode = "group") - - #files - if (file.exists(dump.output.to)) { - htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/averageTravelWait.html")) - #ggsave(paste0(dump.output.to, "/averageTravelWait.png"),width = 6,height = 10, fig) - } else { - dir.create(dump.output.to) - htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/averageTravelWait.html")) - #ggsave(paste0(dump.output.to, "/averageTravelWait.png"),width = 6,height = 10, fig) - } - - # Generating yaml and output_files - if (file.exists(dump.output.to)) { - write.table(avg_time,paste0(dump.output.to,"/averageTravelWait.csv"),row.names = FALSE,sep = ",") - } else { - dir.create(dump.output.to) - write.table(avg_time,paste0(dump.output.to,"/averageTravelWait.csv"),row.names = FALSE,sep = ",") - } - - yaml_list <- list( - header = list(tab = "Summary", title = "Dashboard", description = "Plots from output directory"), - layout = list("1" = list( - title = paste0("Average Travel/Wait Time Chart from ",attr(tripsTable,"table_name")), - description = "generated by plotAverageTravelWait()", - type = "bar", - width = 1, - props = list(dataset = "averageTravelWait.csv", - x = "main_mode", - y = "[trav_time_avg,wait_time_avg]", - yAxisTitle = "Time in minutes", - xAxisTitle = "main_mode") - )) - ) - - if (file.exists(paste0(dump.output.to, dashboard_file))) { - yaml_from_directory <- read_yaml(paste0(dump.output.to, dashboard_file)) - yaml_from_directory$layout <- append(yaml_from_directory$layout, list(new_row = list( - title = paste0("Average Travel/Wait Time Chart from ",attr(tripsTable,"table_name")), - description = "generated by plotAverageTravelWait()", - type = "bar", - width = 1, - props = list(dataset = "averageTravelWait.csv", - x = "main_mode", - y = "[trav_time_avg,wait_time_avg]", - yAxisTitle = "Time in minutes", - xAxisTitle = "main_mode") - ))) - names(yaml_from_directory$layout) <- 1:length(names(yaml_from_directory$layout)) - - write_yaml(yaml_from_directory, paste0(dump.output.to, dashboard_file)) - } else { - write_yaml(yaml_list, paste0(dump.output.to, dashboard_file)) - } - #plotting - if(!only.files){ - - fig - return(fig) - } - -} - - -#' Bar Chart with main_mode on x-axis and average travel/wait time on y-axis -#' -#' Takes Table trips_output (from readTripsTable()), -#' 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') -#' -#' -#' @param tripsTable1 tible of trips_output (from readTripsTable()) -#' @param tripsTable2 tible of trips_output (from readTripsTable()) -#' @param 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 -#' @param united.name character string, if columns were united, you can specify name for the resulting column in chart -#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored -#' @param only.files boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly -#' -#' @return Bar Chart plot of average time spent on travel/wait -#' -#' @export -compareAverageTravelWait <- function(tripsTable1,tripsTable2, unite.columns = character(0), united.name = "united",dump.output.to = matsimDumpOutputDirectory, - only.files = FALSE) { - - # If some columns should be united - if (length(unite.columns) != 0) { - tripsTable1$main_mode[grep(paste0(unite.columns, collapse = "|"), tripsTable1$main_mode)] <- united.name - tripsTable2$main_mode[grep(paste0(unite.columns, collapse = "|"), tripsTable2$main_mode)] <- united.name - } - - avg_time1 = tripsTable1 %>% group_by(main_mode)%>% - summarize(trav_time_avg = hms::hms(seconds_to_period(mean(trav_time))), - wait_time_avg = hms::hms(seconds_to_period(mean(wait_time)))) %>% - mutate(trav_time_avg = minute(trav_time_avg),wait_time_avg = minute(wait_time_avg)) %>% arrange(main_mode) - - #print(avg_time1) - - avg_time2 = tripsTable2 %>% group_by(main_mode)%>% - summarize(trav_time_avg = hms::hms(seconds_to_period(mean(trav_time))), - wait_time_avg = hms::hms(seconds_to_period(mean(wait_time)))) %>% - mutate(trav_time_avg = minute(trav_time_avg),wait_time_avg = minute(wait_time_avg)) %>% arrange(main_mode) - - #print(avg_time2) - - avg_time = full_join(avg_time1, avg_time2, by = "main_mode") %>% - replace_na(list(trav_time_avg.x = 0,wait_time_avg.x = 0,trav_time_avg.y = 0,wait_time_avg.y = 0)) - - #print(avg_time) - - avg_time = avg_time %>% mutate(trav_time_avg = trav_time_avg.x - trav_time_avg.y, - wait_time_avg =wait_time_avg.x - wait_time_avg.y )%>% - select(-wait_time_avg.x,-wait_time_avg.y, -trav_time_avg.x,-trav_time_avg.y) - - #print(avg_time) - - fig = plot_ly(data = avg_time,x = ~main_mode,y = ~trav_time_avg,type = 'bar',name = "AVG Time Travelling") - fig = fig %>% add_trace(y = ~wait_time_avg,name = "AVG Time Waiting") - fig = fig %>% layout(yaxis = list(title = "Time spent (in minutes)"),barmode = "group") - - #files - if (file.exists(dump.output.to)) { - htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/averageTravelWait.html")) - #ggsave(paste0(dump.output.to, "/averageTravelWait.png"),width = 6,height = 10, fig) - } else { - dir.create(dump.output.to) - htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/averageTravelWait.html")) - #ggsave(paste0(dump.output.to, "/averageTravelWait.png"),width = 6,height = 10, fig) - } - - # Generating yaml and output_files - if (file.exists(dump.output.to)) { - write.table(avg_time,paste0(dump.output.to,"/averageTravelWait.csv"),row.names = FALSE,sep = ",") - } else { - dir.create(dump.output.to) - write.table(avg_time,paste0(dump.output.to,"/averageTravelWait.csv"),row.names = FALSE,sep = ",") - } - - yaml_list <- list( - header = list(tab = "Summary", title = "Dashboard", description = "Plots from output directory"), - layout = list("1" = list( - title = paste0("Average Travel/Wait Time Chart from ",attr(tripsTable1,"table_name")," and ",attr(tripsTable2,"table_name")), - description = "generated by plotAverageTravelWait()", - type = "bar", - width = 1, - props = list(dataset = "averageTravelWait.csv", - x = "main_mode", - columns = list("trav_time_avg","wait_time_avg"), - yAxisTitle = "Time in minutes", - xAxisTitle = "main_mode" - ) - )) - ) - - if (file.exists(paste0(dump.output.to, dashboard_file))) { - yaml_from_directory <- read_yaml(paste0(dump.output.to, dashboard_file)) - yaml_from_directory$layout <- append(yaml_from_directory$layout, list(new_row = list( - title = paste0("Average Travel/Wait Time Chart from ",attr(tripsTable1,"table_name")," and ",attr(tripsTable2,"table_name")), - description = "generated by plotAverageTravelWait()", - type = "bar", - width = 1, - props = list(dataset = "averageTravelWait.csv", - x = "main_mode", - columns = list("trav_time_avg","wait_time_avg"), - yAxisTitle = "Time in minutes", - xAxisTitle = "main_mode") - ))) - names(yaml_from_directory$layout) <- 1:length(names(yaml_from_directory$layout)) - - write_yaml(yaml_from_directory, paste0(dump.output.to, dashboard_file)) - } else { - write_yaml(yaml_list, paste0(dump.output.to, dashboard_file)) - } - #plotting - if(!only.files){ - - fig - return(fig) - } - -} - -#' Bar Chart with distance travelled on x-axis and number of trips on y-axis -#' -#' Takes Table trips_output (from readTripsTable()), -#' 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') -#' -#' -#' @param tripsTable tible of trips_output (from readTripsTable()) -#' @param 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 -#' @param united.name character string, if columns were united, you can specify name for the resulting column in chart -#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored -#' @param only.files boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly -#' @return Bar Chart plot of count of trips among distance travelled -#' -#' @export -plotModalDistanceDistribution <- function(tripsTable, unite.columns = character(0), united.name = "united",dump.output.to = matsimDumpOutputDirectory, - only.files = FALSE) { - - - # If some columns should be united - if (length(unite.columns) != 0) { - tripsTable$main_mode[grep(paste0(unite.columns, collapse = "|"), tripsTable$main_mode)] <- united.name - } - modes = levels(factor(tripsTable$main_mode)) - - #This is a very bad way to do that, but I see no other way to get it done - #Also filtering table into a new doesn't creates new objects in memory, so it works fast - tripsTable_05km = tripsTable %>% filter(traveled_distance<=1000) %>% mutate(dist_cat = "0-1km") - #tripsTable_1km = tripsTable %>% filter(traveled_distance>500 & traveled_distance<=1000 ) %>% mutate(dist_cat = "0.5-1km") - tripsTable_2km = tripsTable %>% filter(traveled_distance>1000 & traveled_distance<=2000) %>% mutate(dist_cat = "1-2km") - tripsTable_5km = tripsTable %>% filter(traveled_distance>2000 & traveled_distance<=5000) %>% mutate(dist_cat = "2-5km") - tripsTable_10km = tripsTable %>% filter(traveled_distance>5000 & traveled_distance<=10*1000) %>% mutate(dist_cat = "5-10km") - tripsTable_20km = tripsTable %>% filter(traveled_distance>10*1000 & traveled_distance<=20*1000) %>% mutate(dist_cat = "10-20km") - tripsTable_50km = tripsTable %>% filter(traveled_distance>20*1000 & traveled_distance<=50*1000) %>% mutate(dist_cat = "20-50km") - tripsTable_100km = tripsTable %>% filter(traveled_distance>50*1000 & traveled_distance<=100*1000) %>% mutate(dist_cat = "50-100km") - tripsTable_100pluskm = tripsTable %>% filter(traveled_distance>100*1000) %>% mutate(dist_cat = "> 100km") - - tripsTable_result = rbind(tripsTable_05km, - #tripsTable_1km, - tripsTable_2km, - tripsTable_5km, - tripsTable_10km, - tripsTable_20km, - tripsTable_50km, - tripsTable_100km, - tripsTable_100pluskm) - - - tripsTable_result$dist_cat = factor(tripsTable_result$dist_cat,levels = c("0-1km","1-2km","2-5km","5-10km","10-20km","20-50km","50-100km","> 100km")) - - tableWithCounts = tripsTable_result %>% count(main_mode,dist_cat) - #print(tableWithCounts) - tableToWrite = tripsTable_result %>% select(dist_cat) %>% unique() %>% arrange(dist_cat) - for( mode in modes){ - newColumn = tableWithCounts %>% - filter(main_mode == mode) %>% - mutate(mode = n) %>% - select(dist_cat,mode) - diff = setdiff(tableToWrite$dist_cat,newColumn$dist_cat) - for(dist in diff){ - newColumn = rbind(newColumn,c(dist,0)) - } - newColumn = newColumn %>%arrange(dist_cat) %>% select(-dist_cat) %>% mutate(mode = as.numeric(mode)) - colnames(newColumn)[1] = mode - #print(newColumn) - tableToWrite = cbind(tableToWrite,newColumn) - } - tableToWrite$dist_cat = factor(tableToWrite$dist_cat,ordered = TRUE, - levels = c("0-1km","1-2km","2-5km","5-10km","10-20km","20-50km","50-100km",">100km")) - tableToWrite = tableToWrite %>% arrange(dist_cat) - - - plt = ggplot(tripsTable_result) + - geom_bar(aes(x = dist_cat,fill = main_mode),position = position_dodge())+ - ggtitle("Number of trips per travelling distance") - fig = plotly::ggplotly(plt) - - #files - if (file.exists(dump.output.to)) { - htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/tripsPerDistance.html")) - #ggsave(paste0(dump.output.to, "/averageTravelWait.png"),width = 6,height = 10, fig) - } else { - dir.create(dump.output.to) - htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/tripsPerDistance.html")) - #ggsave(paste0(dump.output.to, "/averageTravelWait.png"),width = 6,height = 10, fig) - } - - # Generating yaml and output_files - if (file.exists(dump.output.to)) { - write.table(tableToWrite,paste0(dump.output.to,"/tripsPerDistance.csv"),row.names = FALSE,sep = ",") - } else { - dir.create(dump.output.to) - write.table(tableToWrite,paste0(dump.output.to,"/tripsPerDistance.csv"),row.names = FALSE,sep = ",") - } - - yaml_list <- list( - header = list(tab = "Summary", title = "Dashboard", description = "Plots from output directory"), - layout = list("1" = list( - title = paste0("Count of trips travelled per distance from ",attr(tripsTable,"table_name")), - description = "generated by plotTripsByDistance()", - type = "bar", - width = 1, - props = list(dataset = "tripsPerDistance.csv", - x = "dist_cat", - y = "[main_mode,n]", - yAxisTitle = "Count of trips", - xAxisTitle = "Distance") - )) - ) - - if (file.exists(paste0(dump.output.to, dashboard_file))) { - yaml_from_directory <- read_yaml(paste0(dump.output.to, dashboard_file)) - yaml_from_directory$layout <- append(yaml_from_directory$layout, list(new_row = list( - title = paste0("Count of trips travelled per distance from ",attr(tripsTable,"table_name")), - description = "generated by plotTripsByDistance()", - type = "bar", - width = 1, - props = list(dataset = "tripsPerDistance.csv", - x = "dist_cat", - y = "[main_mode,n]", - yAxisTitle = "Count of trips", - xAxisTitle = "Distance") - ))) - names(yaml_from_directory$layout) <- 1:length(names(yaml_from_directory$layout)) - - write_yaml(yaml_from_directory, paste0(dump.output.to, dashboard_file)) - } else { - write_yaml(yaml_list, paste0(dump.output.to, dashboard_file)) - } - if(!only.files){ - - fig - return(fig) - } - -} - -#' Bar Chart with distance travelled on x-axis and difference of number of trips on y-axis -#' -#' Takes 2 Tables trips_output (from readTripsTable()), -#' 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') -#' -#' -#' @param tripsTable1 tible of trips_output (from readTripsTable()), number of trips of this table will be extracted from number of trips of tripsTable1 -#' @param tripsTable2 tible of trips_output (from readTripsTable()), from number of trips of this table number of trips of tripsTable1 will be extracted -#' @param 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 -#' @param united.name character string, if columns were united, you can specify name for the resulting column in chart -#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored -#' @param only.files boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly -#' @return Bar Chart plot of count of trips among distance travelled -#' -#' @export -compareModalDistanceDistribution <- function(tripsTable1,tripsTable2, unite.columns = character(0), united.name = "united",dump.output.to = matsimDumpOutputDirectory, - only.files = FALSE) { - if (length(unite.columns) != 0) { - tripsTable1$main_mode[grep(paste0(unite.columns, collapse = "|"), tripsTable1$main_mode)] <- united.name - tripsTable2$main_mode[grep(paste0(unite.columns, collapse = "|"), tripsTable2$main_mode)] <- united.name - - } - - modes = unique(c(unique(tripsTable1$main_mode),unique(tripsTable2$main_mode))) - distribution1 <- appendDistanceCategory(tripsTable1) - distribution2 <- appendDistanceCategory(tripsTable2) - - tableWithCounts1 = distribution1 %>% count(main_mode,dist_cat) - tableWithCounts2 = distribution2 %>% count(main_mode,dist_cat) - - joined <- full_join(tableWithCounts1, tableWithCounts2, by = c("main_mode", "dist_cat")) - - result <- joined %>% - replace_na( list(n.x = 0, n.y = 0) ) %>% - mutate(n = n.y - n.x) %>% - select(main_mode, dist_cat, n) - - - result$dist_cat = factor(result$dist_cat,levels = c("0-1km","1-2km","2-5km","5-10km","10-20km","20-50km","50-100km","> 100km")) - - tableWithCounts = result - #print(tableWithCounts) - tableToWrite = result %>% select(dist_cat) %>% unique() %>% arrange(dist_cat) - for( mode in modes){ - newColumn = tableWithCounts %>% - filter(main_mode == mode) %>% - mutate(mode = n) %>% - select(dist_cat,mode) - diff = setdiff(tableToWrite$dist_cat,newColumn$dist_cat) - for(dist in diff){ - newColumn = rbind(newColumn,c(dist,0)) - } - newColumn = newColumn %>%arrange(dist_cat) %>% select(-dist_cat) %>% mutate(mode = as.numeric(mode)) - colnames(newColumn)[1] = mode - #print(newColumn) - tableToWrite = cbind(tableToWrite,newColumn) - } - tableToWrite$dist_cat = factor(tableToWrite$dist_cat,ordered = TRUE, - levels = c("0-1km","1-2km","2-5km","5-10km","10-20km","20-50km","50-100km",">100km")) - tableToWrite = tableToWrite %>% arrange(dist_cat) - - - fig = ggplotly(ggplot(result) + - geom_col(aes(x = dist_cat,fill = main_mode, y = n), position = position_dodge())+ - ggtitle("Difference in number of trips per travelling distance")) - - - #files - if (file.exists(dump.output.to)) { - htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/modalDistanceDistributionComparison.html")) - #ggsave(paste0(dump.output.to, "/averageTravelWait.png"),width = 6,height = 10, fig) - } else { - dir.create(dump.output.to) - htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/modalDistanceDistributionComparison.html")) - #ggsave(paste0(dump.output.to, "/averageTravelWait.png"),width = 6,height = 10, fig) - } - - # Generating yaml and output_files - if (file.exists(dump.output.to)) { - write.table(tableToWrite,paste0(dump.output.to,"/modalDistanceDistributionComparison.csv"),row.names = FALSE,sep = ",") - } else { - dir.create(dump.output.to) - write.table(tableToWrite,paste0(dump.output.to,"/modalDistanceDistributionComparison.csv"),row.names = FALSE,sep = ",") - } - - #print(list(modes)) - yaml_list <- list( - header = list(tab = "Summary", title = "Dashboard", description = "Plots from output directory"), - layout = list("1" = list( - title = paste0("Modal Distance Distribution Comparison between ",attr(tripsTable1,"table_name")," and ",attr(tripsTable2,"table_name")), - description = "generated by compareModalDistanceDistribution()", - type = "bar", - width = 1, - props = list(dataset = "modalDistanceDistributionComparison.csv", - x = "dist_cat", - columns = as.list(modes), - yAxisTitle = "Number of trips", - xAxisTitle = "dist_cat") - )) - ) - - if (file.exists(paste0(dump.output.to, dashboard_file))) { - yaml_from_directory <- read_yaml(paste0(dump.output.to, dashboard_file)) - yaml_from_directory$layout <- append(yaml_from_directory$layout, list(new_row = list( - title = paste0("Modal Distance Distribution Comparison between ",attr(tripsTable1,"table_name")," and ",attr(tripsTable2,"table_name")), - description = "generated by compareModalDistanceDistribution()", - type = "bar", - width = 1, - props = list(dataset = "modalDistanceDistributionComparison.csv", - x = "dist_cat", - columns = as.list(modes), - yAxisTitle = "Number of trips", - xAxisTitle = "dist_cat") - ))) - names(yaml_from_directory$layout) <- 1:length(names(yaml_from_directory$layout)) - - write_yaml(yaml_from_directory, paste0(dump.output.to, dashboard_file)) - } else { - write_yaml(yaml_list, paste0(dump.output.to, dashboard_file)) - } - - return(fig) - -} - -#' Bar Chart with distance travelled on x-axis and number of trips on y-axis -#' -#' Takes Table trips_output (from readTripsTable()), -#' 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') -#' -#' -#' @param tripsTable tible of trips_output (from readTripsTable()) -#' @param 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 -#' @param united.name character string, if columns were united, you can specify name for the resulting column in chart -#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored -#' @param only.files boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly -#' -#' @return Bar Chart plot of distance traveled per mode -#' -#' @export -plotTripDistanceByMode <- function(tripsTable, unite.columns = character(0), united.name = "united",dump.output.to = matsimDumpOutputDirectory, - only.files = FALSE) { - - - # If some columns should be united - if (length(unite.columns) != 0) { - tripsTable$main_mode[grep(paste0(unite.columns, collapse = "|"), tripsTable$main_mode)] <- united.name - } - modes = levels(factor(tripsTable$main_mode)) - - table_name = (attr(tripsTable,"table_name")) - tripsTable = tripsTable %>% - group_by(main_mode) %>% - summarize(avg_dist = mean(traveled_distance)/1000) - attr(tripsTable,"table_name") = table_name - - text_for_y = round(tripsTable$avg_dist,digits = 2) - fig = plot_ly(data = tripsTable,x = ~main_mode,y = ~avg_dist, - type = 'bar', - text = text_for_y, - textposition = "auto", - name = "AVG Distance traveled by a person over a day") - fig = fig %>% layout(yaxis = list(title = "Distance (kms)"),barmode = "group") - - #files - if (file.exists(dump.output.to)) { - htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/tripsPerDistanceByMode.html")) - #ggsave(paste0(dump.output.to, "/averageTravelWait.png"),width = 6,height = 10, fig) - } else { - dir.create(dump.output.to) - htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/tripsPerDistanceByMode.html")) - #ggsave(paste0(dump.output.to, "/averageTravelWait.png"),width = 6,height = 10, fig) - } - - # Generating yaml and output_files - if (file.exists(dump.output.to)) { - write.table(tripsTable,paste0(dump.output.to,"/tripDistancePerMode.csv"),row.names = FALSE,sep = ",") - } else { - dir.create(dump.output.to) - write.table(tripsTable,paste0(dump.output.to,"/tripDistancePerMode.csv"),row.names = FALSE,sep = ",") - } - - yaml_list <- list( - header = list(tab = "Summary", title = "Dashboard", description = "Plots from output directory"), - layout = list("1" = list( - title = paste0("Average distance traveled by person per mode from ",attr(tripsTable,"table_name")), - description = "generated by plotTripDistanceByMode()", - type = "bar", - width = 1, - props = list(dataset = "tripDistancePerMode.csv", - x = "main_mode", - y = "[avg_dist]", - yAxisTitle = "Distance (kms)", - xAxisTitle = "Main_mode") - )) - ) - - if (file.exists(paste0(dump.output.to, dashboard_file))) { - yaml_from_directory <- read_yaml(paste0(dump.output.to, dashboard_file)) - yaml_from_directory$layout <- append(yaml_from_directory$layout, list(new_row = list( - title = paste0("Average distance traveled by person per mode from ",attr(tripsTable,"table_name")), - description = "generated by plotTripDistanceByMode()", - type = "bar", - width = 1, - props = list(dataset = "tripDistancePerMode.csv", - x = "main_mode", - y = "[avg_dist]", - yAxisTitle = "Distance (kms)", - xAxisTitle = "Main_mode") - ))) - names(yaml_from_directory$layout) <- 1:length(names(yaml_from_directory$layout)) - - write_yaml(yaml_from_directory, paste0(dump.output.to, dashboard_file)) - } else { - write_yaml(yaml_list, paste0(dump.output.to, dashboard_file)) - } - if(!only.files){ - - - - fig - return(fig) - } -} - - - -#' Line plot with departure time x-axis and number of trips on y-axis -#' -#' Takes Table trips_output (from readTripsTable()), -#' 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') -#' -#' -#' @param tripsTable tible of trips_output (from readTripsTable()) -#' @param 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 -#' @param united.name character string, if columns were united, you can specify name for the resulting column in chart -#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored -#' @param only.files boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly -#' @return Line Chart plot of trips count by departure mode per mode -#' -#' @export -plotTripCountByDepTime <- function(tripsTable, unite.columns = character(0), united.name = "united",dump.output.to = matsimDumpOutputDirectory, - only.files = FALSE) { - - - # If some columns should be united - if (length(unite.columns) != 0) { - tripsTable$main_mode[grep(paste0(unite.columns, collapse = "|"), tripsTable$main_mode)] <- united.name - } - modes = levels(factor(tripsTable$main_mode)) - - - - table_name = (attr(tripsTable,"table_name")) - - tripsTable = tripsTable %>% - mutate(dep_time = hour(dep_time)) %>% - count(dep_time,main_mode) - - attr(tripsTable,"table_name") = table_name #reset table_name - #text_for_y = round(tripsTable$avg_dist,digits = 2) - - - tableToWrite = tripsTable %>% select(dep_time) %>% unique() %>% arrange(dep_time) - for( mode in modes){ - newColumn = tripsTable %>% - filter(main_mode == mode) %>% - mutate(mode = n) %>% - select(dep_time,mode) - for(i in tableToWrite$dep_time){ - if(!i %in% newColumn$dep_time){ - newColumn = rbind(newColumn,c(i,0)) - } - } - #diff = setdiff(tableToWrite$dist_cat,newColumn$dist_cat) - #for(dist in diff){ - #newColumn = rbind(newColumn,c(dist,0)) - #} - newColumn = newColumn %>% arrange(dep_time) %>% select(-dep_time) %>% mutate(mode = as.numeric(mode)) - colnames(newColumn)[1] = mode - #print(newColumn) - tableToWrite = cbind(tableToWrite,newColumn) - } - #print(tableToWrite) - - fig = plot_ly(tripsTable,x = ~dep_time,y = ~n,type = "scatter",mode = "line",linetype = ~main_mode) - fig = fig %>% layout(yaxis = list(title = "Count of trips per departure Time"),barmode = "group") - - #files - if (file.exists(dump.output.to)) { - htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/countTripsByDep.html")) - #ggsave(paste0(dump.output.to, "/averageTravelWait.png"),width = 6,height = 10, fig) - } else { - dir.create(dump.output.to) - htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/countTripsByDep.html")) - #ggsave(paste0(dump.output.to, "/averageTravelWait.png"),width = 6,height = 10, fig) - } - - # Generating yaml and output_files - if (file.exists(dump.output.to)) { - write.table(tableToWrite,paste0(dump.output.to,"/countTripsByDep.csv"),row.names = FALSE,sep = ",") - } else { - dir.create(dump.output.to) - write.table(tableToWrite,paste0(dump.output.to,"/countTripsByDep.csv"),row.names = FALSE,sep = ",") - } - - yaml_list <- list( - header = list(tab = "Summary", title = "Dashboard", description = "Plots from output directory"), - layout = list("1" = list( - title = paste0("Trips counted by departure time from ",attr(tripsTable,"table_name")), - description = "generated by plotTripCountByDepTime()", - type = "line", - width = 1, - props = list(dataset = "countTripsByDep.csv", - x = "dep_time", - y = "[n]", - yAxisTitle = "Count of trips", - xAxisTitle = "departure time") - )) - ) - - if (file.exists(paste0(dump.output.to, dashboard_file))) { - yaml_from_directory <- read_yaml(paste0(dump.output.to, dashboard_file)) - yaml_from_directory$layout <- append(yaml_from_directory$layout, list(new_row = list( - title = paste0("Trips counted by departure time from ",attr(tripsTable,"table_name")), - description = "generated by plotTripCountByDepTime()", - type = "line", - width = 1, - props = list(dataset = "countTripsByDep.csv", - x = "dep_time", - y = "[n]", - yAxisTitle = "Count of trips", - xAxisTitle = "departure time") - ))) - names(yaml_from_directory$layout) <- 1:length(names(yaml_from_directory$layout)) - - write_yaml(yaml_from_directory, paste0(dump.output.to, dashboard_file)) - } else { - write_yaml(yaml_list, paste0(dump.output.to, dashboard_file)) - } - if(!only.files){ - - fig - return(fig) - } -} - -#' Line plot that shows the number of activities ending at a given time, per activity type. -#' The activity end time is derived from the departure time in the given trips tibble. -#' -#' Takes Table trips_output (from readTripsTable()), -#' 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') -#' -#' -#' @param tripsTable tible of trips_output (from readTripsTable()) -#' @param unite.columns vector of character strings, that represent patterns of columns to be united, changes name of all activity types in the tibble copy to united.name = "united" that matches PATTERNS given in unite.columns -#' @param united.name character string, if columns were united, you can specify name for the resulting column in chart -#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored -#' @param only.files boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly -#' @return Line plot with departure time x-axis and number start activities on y-axis -#' -#' @export -plotActivityEndTimes <- function(tripsTable, unite.columns = character(0), united.name = "united",dump.output.to = matsimDumpOutputDirectory, - only.files = FALSE) { - - - # If some columns should be united - if (length(unite.columns) != 0) { - tripsTable$start_activity_type[grep(paste0(unite.columns, collapse = "|"), tripsTable$start_activity_type)] <- united.name - } - - - table_name = (attr(tripsTable,"table_name")) - - tripsTable = tripsTable %>% - mutate(dep_time = hour(dep_time),start_activity_type = sapply(strsplit(start_activity_type,"_"),"[[",1)) %>% - count(dep_time,start_activity_type) - - attr(tripsTable,"table_name") = table_name #reset table_name - #text_for_y = round(tripsTable$avg_dist,digits = 2) - - activities = levels(factor(tripsTable$start_activity_type)) - - tableToWrite = tripsTable %>% select(dep_time) %>% unique() %>% arrange(dep_time) - for( act in activities){ - newColumn = tripsTable %>% - filter(start_activity_type == act) %>% - mutate(act = n) %>% - select(dep_time,act) - diff = setdiff(tableToWrite$dep_time,newColumn$dep_time) - for(dtime in diff){ - newColumn = rbind(newColumn,c(dtime,0)) - } - newColumn = newColumn %>%arrange(dep_time) %>% select(-dep_time) %>% mutate(act = as.numeric(act)) - colnames(newColumn)[1] = act - #print(newColumn) - tableToWrite = cbind(tableToWrite,newColumn) - } - - fig = plot_ly(tripsTable,x = ~dep_time,y = ~n,type = "scatter",mode = "line",linetype = ~start_activity_type) - fig = fig %>% layout(yaxis = list(title = "Number of activities ending [n]"), - xaxis = list(title = "Time [h]"), - barmode = "group") - - - #files - #if (file.exists(dump.output.to)) { - # htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/countTripsByDep.html")) - #} else { - # dir.create(dump.output.to) - # htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/countTripsByDep.html")) -# -# } - - # Generating yaml and output_files - if (! file.exists(dump.output.to)) { - dir.create(dump.output.to) - } - - write.table(tableToWrite,paste0(dump.output.to,"/activityEndTimes.csv"),row.names = FALSE,sep = ",") - - yaml_list <- list( - header = list(tab = "Summary", title = "Dashboard", description = "Plots from output directory"), - layout = list("1" = list( - title = paste0("Activity End Times ",attr(tripsTable,"table_name")), - description = "generated by plotActivityEndTimes()", - type = "bar", - width = 1, - props = list(dataset = "activityEndTimes.csv", - x = "dep_time", - y = "[n]", - yAxisTitle = "Number of activities [n]", - xAxisTitle = "Time [h]", - stacked= TRUE) - )) - ) - - if (file.exists(paste0(dump.output.to, dashboard_file))) { - yaml_from_directory <- read_yaml(paste0(dump.output.to, dashboard_file)) - yaml_from_directory$layout <- append(yaml_from_directory$layout, list(new_row = list( - title = paste0("Activity End Times ",attr(tripsTable,"table_name")), - description = "generated by plotActivityEndTimes()", - type = "bar", - width = 1, - props = list(dataset = "activityEndTimes.csv", - x = "dep_time", - y = "[n]", - yAxisTitle = "Number of activities [n]", - xAxisTitle = "Time [h]", - stacked = TRUE) - ))) - names(yaml_from_directory$layout) <- 1:length(names(yaml_from_directory$layout)) - - write_yaml(yaml_from_directory, paste0(dump.output.to, dashboard_file)) - } else { - write_yaml(yaml_list, paste0(dump.output.to, dashboard_file)) - } - if(!only.files){ - fig - return(fig) - } - -} - -#' This function plots the number of trips ending per trip purpose over time. The trip purpose corresponds to the activity type of the destination activity of a given trip. -#' Thus, the y-axis of the plot can also be interpreted as the number of activities starting (based on the assumption that trip end time = activity start time). -#' -#' Takes Table trips_output (from readTripsTable()), -#' 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') -#' -#' -#' @param tripsTable tibble of trips_output (from readTripsTable()) -#' @param unite.columns vector of character strings, that represent patterns of columns to be united, changes name of all activity types in the tibble copy to united.name = "united" that matches PATTERNS given in unite.columns -#' @param united.name character string, if columns were united, you can specify name for the resulting column in plot -#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored -#' @param only.files boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly -#' -#' @return Line plot with arrival time x-axis and number end activities on y-axis -#' -#' @export -plotArrivalTimesPerTripPurpose <- function(tripsTable, unite.columns = character(0), united.name = "united",dump.output.to = matsimDumpOutputDirectory, - only.files = FALSE) { - - - # If some columns should be united - if (length(unite.columns) != 0) { - tripsTable$end_activity_type[grep(paste0(unite.columns, collapse = "|"), tripsTable$end_activity_type)] <- united.name - } - - - table_name = (attr(tripsTable,"table_name")) - - tripsTable = tripsTable %>% - mutate(arr_time = hour(hms(tripsTable$dep_time)+hms(tripsTable$trav_time))) %>% - mutate(end_activity_type = sapply(strsplit(end_activity_type,"_"),"[[",1)) %>% - count(arr_time,end_activity_type) - - attr(tripsTable,"table_name") = table_name #reset table_name - #text_for_y = round(tripsTable$avg_dist,digits = 2) - - activities = levels(factor(tripsTable$end_activity_type)) - - tableToWrite = tripsTable %>% select(arr_time) %>% unique() %>% arrange(arr_time) - for( act in activities){ - newColumn = tripsTable %>% - filter(end_activity_type == act) %>% - mutate(act = n) %>% - select(arr_time,act) - diff = setdiff(tableToWrite$arr_time,newColumn$arr_time) - for(dtime in diff){ - newColumn = rbind(newColumn,c(dtime,0)) - } - newColumn = newColumn %>%arrange(arr_time) %>% select(-arr_time) %>% mutate(act = as.numeric(act)) - colnames(newColumn)[1] = act - #print(newColumn) - tableToWrite = cbind(tableToWrite,newColumn) - } - - fig = plot_ly(tripsTable,x = ~arr_time,y = ~n,type = "scatter",mode = "line",linetype = ~end_activity_type) - fig = fig %>% layout(yaxis = list(title = "Number of trips ending per trip purpose / Count of activities starting"), - xaxis = list(title = "Time [h]"), - barmode = "group") - - - # #files - # if (file.exists(dump.output.to)) { - # htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/countEndActByArr.html")) - # } else { - # dir.create(dump.output.to) - # htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/countEndActByArr.html")) -# - # } - - # Generating yaml and output_files - if (! file.exists(dump.output.to)) { - dir.create(dump.output.to) - } - write.table(tableToWrite,paste0(dump.output.to,"/countActStartsByTime.csv"),row.names = FALSE,sep = ",") - - yaml_list <- list( - header = list(tab = "Summary", title = "Dashboard", description = "Plots from output directory"), - layout = list("1" = list( - title = paste0("Activity Start Times ",attr(tripsTable,"table_name")), - description = "generated by plotArrivalTimesPerTripPurpose()", - type = "bar", - width = 1, - props = list(dataset = "countActStartsByTime.csv", - x = "arr_time", - y = "[n]", - yAxisTitle = "Number of activities starting / trips ending with purpose", - xAxisTitle = "Time [h]", - stacked = TRUE) - )) - ) - - if (file.exists(paste0(dump.output.to, dashboard_file))) { - yaml_from_directory <- read_yaml(paste0(dump.output.to, dashboard_file)) - yaml_from_directory$layout <- append(yaml_from_directory$layout, list(new_row = list( - title = paste0("Activity Start Times ",attr(tripsTable,"table_name")), - description = "generated by plotArrivalTimesPerTripPurpose()", - type = "bar", - width = 1, - props = list(dataset = "countActStartsByTime.csv", - x = "arr_time", - y = "[n]", - yAxisTitle = "Number of activities starting / trips ending with purpose", - xAxisTitle = "Time [h]", - stacked = TRUE) - ))) - names(yaml_from_directory$layout) <- 1:length(names(yaml_from_directory$layout)) - - write_yaml(yaml_from_directory, paste0(dump.output.to, dashboard_file)) - } else { - write_yaml(yaml_list, paste0(dump.output.to, dashboard_file)) - } - if(!only.files){ - fig - return(fig) - } - -} - - -#' This function plots the number of trips starting per trip purpose over time. The trip purpose corresponds to the activity type of the destination activity of a given trip. -#' -#' Takes Table trips_output (from readTripsTable()), -#' 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') -#' -#' -#' @param tripsTable tibble of trips_output (from readTripsTable()) -#' @param unite.columns vector of character strings, that represent patterns of columns to be united, changes name of all activity types in the tibble copy to united.name = "united" that matches PATTERNS given in unite.columns -#' @param united.name character string, if columns were united, you can specify name for the resulting column in plot -#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored -#' @param only.files boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly -#' -#' @return Line plot with arrival time x-axis and number end activities on y-axis -#' -#' @export -plotDepartureTimesPerTripPurpose <- function(tripsTable, unite.columns = character(0), united.name = "united",dump.output.to = matsimDumpOutputDirectory, - only.files = FALSE) { - - - # If some columns should be united - if (length(unite.columns) != 0) { - tripsTable$end_activity_type[grep(paste0(unite.columns, collapse = "|"), tripsTable$end_activity_type)] <- united.name - } - - - table_name = (attr(tripsTable,"table_name")) - - tripsTable = tripsTable %>% - mutate(dep_time = hour(dep_time)) %>% - mutate(end_activity_type = sapply(strsplit(end_activity_type,"_"),"[[",1)) %>% - count(dep_time,end_activity_type) - - attr(tripsTable,"table_name") = table_name #reset table_name - #text_for_y = round(tripsTable$avg_dist,digits = 2) - - activities = levels(factor(tripsTable$end_activity_type)) - - tableToWrite = tripsTable %>% select(dep_time) %>% unique() %>% arrange(dep_time) - for( act in activities){ - newColumn = tripsTable %>% - filter(end_activity_type == act) %>% - mutate(act = n) %>% - select(dep_time,act) - diff = setdiff(tableToWrite$dep_time,newColumn$dep_time) - for(dtime in diff){ - newColumn = rbind(newColumn,c(dtime,0)) - } - newColumn = newColumn %>%arrange(dep_time) %>% select(-dep_time) %>% mutate(act = as.numeric(act)) - colnames(newColumn)[1] = act - #print(newColumn) - tableToWrite = cbind(tableToWrite,newColumn) - } - - fig = plot_ly(tripsTable,x = ~dep_time,y = ~n,type = "scatter",mode = "line",linetype = ~end_activity_type) - fig = fig %>% layout(yaxis = list(title = "Number of trips starting per trip purpose"), - xaxis = list(title = "Time [h]"), - barmode = "group") - - - # #files - # if (file.exists(dump.output.to)) { - # htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/countEndActByArr.html")) - # } else { - # dir.create(dump.output.to) - # htmlwidgets::saveWidget(fig,paste0(dump.output.to, "/countEndActByArr.html")) -# - # } - - # Generating yaml and output_files - if (! file.exists(dump.output.to)) { - dir.create(dump.output.to) - } - write.table(tableToWrite,paste0(dump.output.to,"/countDepartureTimesByTime.csv"),row.names = FALSE,sep = ",") - - yaml_list <- list( - header = list(tab = "Summary", title = "Dashboard", description = "Plots from output directory"), - layout = list("1" = list( - title = paste0("Trip Departure Times per Trip Purpose",attr(tripsTable,"table_name")), - description = "generated by plotDepartureTimesPerTripPurpose()", - type = "bar", - width = 1, - props = list(dataset = "countDepartureTimesByTime.csv", - x = "dep_time", - y = "[n]", - yAxisTitle = "Number of trips starting [n]", - xAxisTitle = "Time [h]", - stacked = TRUE) - )) - ) - - if (file.exists(paste0(dump.output.to, dashboard_file))) { - yaml_from_directory <- read_yaml(paste0(dump.output.to, dashboard_file)) - yaml_from_directory$layout <- append(yaml_from_directory$layout, list(new_row = list( - title = paste0("Trip Departure Times per Trip Purpose",attr(tripsTable,"table_name")), - description = "generated by plotDepartureTimesPerTripPurpose()", - type = "bar", - width = 1, - props = list(dataset = "countDepartureTimesByTime.csv", - x = "dep_time", - y = "[n]", - yAxisTitle = "Number of trips starting [n]", - xAxisTitle = "Time [h]", - stacked = TRUE) - ))) - names(yaml_from_directory$layout) <- 1:length(names(yaml_from_directory$layout)) - - write_yaml(yaml_from_directory, paste0(dump.output.to, dashboard_file)) - } else { - write_yaml(yaml_list, paste0(dump.output.to, dashboard_file)) - } - if(!only.files){ - fig - return(fig) - } - -} - - -#' Bar Chart with tripType on x-axis and travelled distance on y-axis -#' -#' Takes Table trips_output (from readTripsTable()), -#' to plot bar chart with with values that represent -#' travelled distance of each tripType related to the shapeTable -#' -#' -#' @param tripsTable tible of trips_output (from readTripsTable()) -#' @param shapeTable sf object(data.frame with geometries), can be received by using st_read(path_to_geographical_file) -#' @param crs numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation -#' @param dump.output.to folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored -#' -#' @return Bar Chart plot of distance traveled by type -#' -#' @export -plotTripDistancedByType <- function(tripsTable,shapeTable,crs,dump.output.to = matsimDumpOutputDirectory) { - - #Getting all the trip types - filtered_inside = filterByRegion(tripsTable,shapeTable,crs) - filtered_outside = filterByRegion(tripsTable,shapeTable,crs,start.inshape = FALSE,end.inshape = FALSE) - filtered_origin = filterByRegion(tripsTable,shapeTable,crs,start.inshape = TRUE,end.inshape = FALSE) - filtered_destinating = filterByRegion(tripsTable,shapeTable,crs,start.inshape = FALSE,end.inshape = TRUE) - #Adding collumn representing type - filtered_inside = filtered_inside %>% mutate(type = "inside") - filtered_outside = filtered_outside %>% mutate(type = "outside") - filtered_origin = filtered_origin %>% mutate(type = "origin") - filtered_destinating = filtered_origin %>% mutate(type = "destinating") - #Adding all the subtables - result = rbind(filtered_inside,filtered_outside,filtered_destinating,filtered_origin) - #For plotting - travelled = result %>% group_by(type) %>% summarize(travelled = sum(traveled_distance)/1000) - fig = plot_ly(data = travelled,x = ~type,y = ~travelled,type = 'bar',name = "Distance travelled by trip Type") - fig = fig %>% layout(yaxis = list(title = "Distance travelled (in kms)"),barmode = "group") - fig - return(fig) -} - - - -#' Plot alluvial/sankey diagram of transport mode changes -#' -#' Takes two trips_table (from readTripsTable), 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 -#' -#' @param tripsTable1 tible of trips_output (from readTripsTable()) -#' @param tripsTable2 tible of trips_output (from readTripsTable()) -#' @param show.onlyChanges boolean, if it is set to TRUE => sankey diagram only contains changes on axes -#' @param unite.columns vector of character string, changes name of all transport modes in the tibble copy to united.name = "united" that matches PATTERNS given in unite.columns -#' @param united.name if columns were united, you can specify name for the resulting column in plot -#' @param dump.output.to folder that saves and configures yaml for simwrapper. folder where png of plot is stored -#' -#' @return Alluvial diagram that represents changes in transport mode distribution of trip tables -#' -#' @export -plotModalShiftSankey <- function(tripsTable1, tripsTable2, show.onlyChanges = FALSE, unite.columns = character(0), united.name = "united", dump.output.to = matsimDumpOutputDirectory) { - StatStratum <- ggalluvial::StatStratum - joined <- as_tibble(inner_join(tripsTable1, tripsTable2 %>% - select(trip_id, main_mode), by = "trip_id") %>% - dplyr::rename(base_mode = main_mode.x, policy_mode = main_mode.y)) - - if (show.onlyChanges == TRUE) { - joined <- joined %>% - filter(base_mode != policy_mode) - } - - joined <- joined %>% - group_by(base_mode, policy_mode) %>% - count() - - # If the unite.commercials flag is set to TRUE, then join all commercials under 1 name commercial - if (length(unite.columns) != 0) { - joined$base_mode[grep(paste0(unite.columns, collapse = "|"), joined$base_mode)] <- united.name - joined$policy_mode[grep(paste0(unite.columns, collapse = "|"), joined$policy_mode)] <- united.name - } - # Generating yaml and output_files - if (file.exists(dump.output.to)) { - write.csv2(joined, paste0(dump.output.to, "/modalShift.csv"), row.names = FALSE) - } else { - dir.create(dump.output.to) - write.csv2(joined, paste0(dump.output.to, "/modalShift.csv"), row.names = FALSE) - } - - yaml_list <- list(csv = "/modalShift.csv", title = "Modal Shift Sankey Diagram", description = "generated by plotModalShift") - - write_yaml(yaml_list, paste0(dump.output.to, "/sankey-modalshift.yaml")) - - - - - plt = ggplot(joined, aes(y = n, axis1 = base_mode, axis2 = policy_mode)) + - geom_alluvium(aes(fill = base_mode), width = 1 / 8, knot.pos = 0) + - geom_stratum(width = 1 / 8, alpha = 0.25) + - geom_text(stat = "stratum", aes(label = after_stat(stratum)), size = 3) + - scale_x_discrete(limits = c("Base Mode", "Policy Mode"), expand = c(.05, .05)) - plt - return(plt) -} - -#' Plot bar chart diagram of transport mode changes -#' -#' Takes two trips_table (from readTripsTable), 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 -#' -#' @param tripsTable1 tible of trips_output (from readTripsTable()) -#' @param tripsTable2 tible of trips_output (from readTripsTable()) -#' @param unite.columns vector of character string, changes name of all transport modes in the tibble copy to united.name = "united" that matches PATTERNS given in unite.columns -#' @param united.name if columns were united, you can specify name for the resulting column in plot -#' @param dump.output.to folder that saves and configures yaml for simwrapper. folder where png of plot is stored -#' -#' @return plots Bar Chart of transport mode changes with additional files for simwrapper -#' -#' @export -plotModalShiftBar <- function(tripsTable1, tripsTable2, unite.columns = character(0), united.name = "united", dump.output.to = matsimDumpOutputDirectory, - output.name = "modalShiftBarChart") { - # If the unite.columns is specified, then - #print(dump.output.to) - if (length(unite.columns) != 0) { - tripsTable1$main_mode[grep(paste0(unite.columns, collapse = "|"), tripsTable1$main_mode)] <- united.name - tripsTable2$main_mode[grep(paste0(unite.columns, collapse = "|"), tripsTable2$main_mode)] <- united.name - } - tripsTable1 = tripsTable1 %>% mutate(type = "base") - tripsTable2 = tripsTable2 %>% mutate(type = "policy") - - total_trips = rbind(tripsTable1,tripsTable2) - - plt = ggplot(total_trips, aes(x =main_mode,fill = factor(type)))+ - geom_bar(position = position_dodge())+ - coord_flip() - plotly::ggplotly(plt) - - if (file.exists(dump.output.to)) { - ggsave(paste0(dump.output.to,"/",output.name,".png"), plt,device = "png") - } else { - dir.create(dump.output.to) - ggsave(paste0(dump.output.to,"/",output.name,".png"), plt,device = "png") - } - - return(plotly::ggplotly(plt)) -} - -#' Transforms trips_table tibble (from readTripsTable) from tibble to sf (table with attribute features and geometry feature) -#' -#' Takes trips_table (from readTripsTable) 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 -#' -#' @param table tibble of trips_output (from readTripsTable()) -#' -#' @param crs numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation -#' -#' @param 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!!! -#' -#' @return sf object (data.frame with geometries depending to geometry.type) -#' -#' @export -transformToSf <- function(table, crs, geometry.type = st_multipoint()) { - if (class(geometry.type)[2] == "POINT") { - table1 <- table %>% - # mutate(wkt = paste("MULTIPOINT(", start_x, " ", start_y, ",", end_x, " ", end_y, ")", sep ="")) - mutate(start_wkt = paste("POINT(", start_x, " ", start_y, ")", sep = "")) - table2 <- table %>% - mutate(end_wkt = paste("POINT(", end_x, " ", end_y, ")", sep = "")) - attr(table, "geometry.type") <- "POINT" - - - table1_wkt <- st_as_sf(table1, wkt = "start_wkt") %>% select(-start_x, -start_y, -end_x, -end_y) - table2_wkt <- st_as_sf(table2, wkt = "end_wkt") %>% select(-start_x, -start_y, -end_x, -end_y) - - - result_table <- table1_wkt %>% mutate(end_wkt = table2_wkt$end_wkt) - st_geometry(result_table) <- "start_wkt" - st_crs(result_table) <- crs - st_geometry(result_table) <- "end_wkt" - st_crs(result_table) <- crs - st_geometry(result_table) <- "start_wkt" - return(result_table) - } else if (class(geometry.type)[2] == "MULTIPOINT") { - table <- table %>% - mutate(wkt = paste("MULTIPOINT(", start_x, " ", start_y, ",", end_x, " ", end_y, ")", sep = "")) - attr(table, "geometry.type") <- "MULTIPOINT" - - - result_table <- st_as_sf(table, wkt = "wkt") %>% select(-start_x, -start_y, -end_x, -end_y) - - st_crs(result_table) <- crs - return(result_table) - } else if (class(geometry.type)[2] == "LINESTRING") { - table <- table %>% - mutate(wkt = paste("LINESTRING(", start_x, " ", start_y, ",", end_x, " ", end_y, ")", sep = "")) - attr(table, "geometry.type") <- "LINESTRING" - - - result_table <- st_as_sf(table, wkt = "wkt") %>% select(-start_x, -start_y, -end_x, -end_y) - - st_crs(result_table) <- crs - return(result_table) - } else { - return(NA) - } -} - -#' Filtering of trips_table(from readTripsTable) 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 -#' -#' @param tripsTable tibble of trips_output (from readTripsTable()) -#' -#' @param shapeTable sf object(data.frame with geometries), can be received by using st_read(path_to_geographical_file) -#' -#' @param crs numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation -#' -#' @param start.inshape bool, defines trips to conclude (see Description) -#' -#' @param end.inshape bool, defines trips to conclude (see Description) -#' -#' @return tibble, with filtered trips depending on shapeTable and special flags (see Description) -#' -#' @export -filterByRegion <- function(tripsTable, shapeTable, crs, start.inshape = TRUE, end.inshape = TRUE) { - - # shapeTable <- st_read(shapeFile) - if (st_crs(shapeTable) == NA) { - st_crs(shapeTable) <- crs - } - - sf_table <- transformToSf(tripsTable, crs = crs, geometry.type = st_point()) - shapeTable <- st_transform(shapeTable, crs = crs) - # shapeTable isn't table - shape - - union_shape <- st_union(shapeTable) # transforms the crs back to the previous in the file - union_shape <- st_transform(union_shape, crs = st_crs(shapeTable)) - - - st_geometry(sf_table) <- "start_wkt" # Set start_wkt as an active geometry - cont1 <- st_contains(union_shape, sf_table)[[1]] # Indexes of rows where start point is in shapefile - - st_geometry(sf_table) <- "end_wkt" # Set end_wkt as and active geometry - cont2 <- st_contains(union_shape, sf_table)[[1]] # Indexes of rows where end point is in shapefile - - # get trips that ended outside of shape - cont_end_outside <- setdiff(1:nrow(sf_table), cont2) - - # get trips that started outside of shape - cont_start_outside <- setdiff(1:nrow(sf_table), cont1) - - if (start.inshape == TRUE && end.inshape == TRUE) { - cont_union <- intersect(cont1, cont2) - } else if (start.inshape == TRUE && end.inshape == FALSE) { - cont_union <- intersect(cont1, cont_end_outside) - } else if (start.inshape == FALSE && end.inshape == TRUE) { - cont_union <- intersect(cont2, cont_start_outside) - } else { - cont_union <- intersect(cont_start_outside, cont_end_outside) # Give back trips that are neither starting and ending outside the area - } - - - return(tripsTable[cont_union, ]) -} - -#' Plots result of filtered trips on the map (from shape) -#' -#' 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 -#' -#' @param table tibble of trips_output (from readTripsTable()) -#' -#' @param shapeTable sf object(data.frame with geometries), can be received by using st_read(path_to_geographical_file) -#' -#' @param crs numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation -#' -#' @param start.inshape bool, defines trips to conclude (see Description) -#' -#' @param end.inshape bool, defines trips to conclude (see Description) -#' -#' @param optimized bool, by default FALSE and gives interactive plot using leaflet, if TRUE using image with ggplot -#' -#' -#' @return plot with trips filtered depending on flags *.inshape on map from shapeTable -#' -#' @export -plotMapWithFilteredTrips <- function(table, shapeTable, crs, start.inshape = TRUE, end.inshape = TRUE, optimized = FALSE) { - # table = table[1:5000,] #To make plotting faster - # table_sf = transformToSf(table,crs = crs) - filtered <- filterByRegion(table, shapeTable, crs = crs, start.inshape, end.inshape) - if (nrow(filtered) == 0) { - ggplot() + - geom_sf(data = shapeTable) - warning("there is no trip filtered for this map") - } - filtered_sf <- transformToSf(filtered, crs = crs, geometry.type = st_point()) - st_geometry(filtered_sf) <- "start_wkt" - filtered_sf_start <- filtered_sf %>% select(-end_wkt) - st_geometry(filtered_sf) <- "end_wkt" - filtered_sf_end <- filtered_sf %>% select(-start_wkt) - # shape = st_read(shapePath) - if (st_crs(shapeTable) == NA) { - ct_crs(shapeTable) <- crs - } - shapeTable <- st_transform(shapeTable, crs = "+proj=longlat +datum=WGS84 +no_defs") - filtered_sf_start <- st_transform(filtered_sf_start, "+proj=longlat +datum=WGS84 +no_defs") - filtered_sf_end <- st_transform(filtered_sf_end, "+proj=longlat +datum=WGS84 +no_defs") - - if (optimized) { - colors <- c("Start" = "blue", "End" = "red") - shapes <- c("Start" = 5, "End" = 3) - # ggplot2 isn't interactive! - plt <- ggplot() + - geom_sf(data = shapeTable) + - # geom_sf(data = ) - geom_sf(data = filtered_sf_start, aes(color = "Start"), size = 1, shape = 5) + - geom_sf(data = filtered_sf_end, aes(color = "End"), size = 1, shape = 3) + - labs(color = "Type") + - scale_colour_manual(values = colors) - plt - return(plt) - } - - - - - - # If we need to change design - # css_fix <- "div.info.legend.leaflet-control br {clear: both;}" - # Convert CSS to HTML - # html_fix <- htmltools::tags$style(type = "text/css", css_fix) - - - plt <- leaflet() %>% - addTiles() %>% - addProviderTiles( - "OpenStreetMap", - # give the layer a name - group = "OpenStreetMap" - ) %>% - addProviderTiles( - "Stamen.Toner", - group = "Stamen.Toner" - ) %>% - addProviderTiles( - "Stamen.Terrain", - group = "Stamen.Terrain" - ) %>% - addProviderTiles( - "Esri.WorldStreetMap", - group = "Esri.WorldStreetMap" - ) %>% - addProviderTiles( - "Wikimedia", - group = "Wikimedia" - ) %>% - addProviderTiles( - "CartoDB.Positron", - group = "CartoDB.Positron" - ) %>% - addProviderTiles( - "Esri.WorldImagery", - group = "Esri.WorldImagery" - ) %>% - addPolygons(data = shapeTable, opacity = 0.1, color = "green") %>% - addCircleMarkers(filtered_sf_start, - lng = st_coordinates(filtered_sf_start$start_wkt)[, 1], - lat = st_coordinates(filtered_sf_start$start_wkt)[, 2], radius = 3, color = "blue", - label = paste( - "Person_id:", - filtered_sf_start$person, "
", - "Trip_id:", - filtered_sf_start$trip_id, "
", - "main_mode:", filtered_sf_start$main_mode, "
", - "type:", "start", "
", - "Start activity:", - filtered_sf_start$start_activity_type, "
" - ) %>% lapply(htmltools::HTML) - ) %>% - addCircleMarkers(filtered_sf_end, - lng = st_coordinates(filtered_sf_end$end_wkt)[, 1], - lat = st_coordinates(filtered_sf_end$end_wkt)[, 2], radius = 0.15, color = "red", - label = paste( - "Person_id:", - filtered_sf_end$person, "
", - "Trip_id:", - filtered_sf_end$trip_id, "
", - "main_mode:", filtered_sf_end$main_mode, "
", - "type:", "end", "
", - "End activity:", - filtered_sf_end$end_activity_type, "
" - ) %>% lapply(htmltools::HTML) - ) %>% - addLegend( - colors = c("blue", "red"), - labels = c("Start of trip", "End of trip"), - position = "bottomleft", - title = "Type of the point", - opacity = 0.9 - ) %>% - addMiniMap() %>% - addLayersControl( - baseGroups = c( - "OpenStreetMap", "Stamen.Toner", - "Stamen.Terrain", "Esri.WorldStreetMap", - "Wikimedia", "CartoDB.Positron", "Esri.WorldImagery" - ), - # position it on the topleft - position = "topleft" - ) - - return(plt) -} - -#' Plots start and end coordinates of the given trips table on an osm map -#' -#' @param table tibble of trips_output (from readTripsTable()) -#' -#' -#' @param crs numeric representation of the EPSG code or proj4string for the corresponding coordinate system of the trip coordinates, can be found in network file from output directory of MATSim simulation -#' -#' @param optimized bool, by default FALSE and gives interactive plot using leaflet, if TRUE using image with ggplot -#' -#' -#' @return plot with trips -#' -#' @export -plotMapWithTrips <- function(table, crs, optimized = FALSE) { - table_sf <- transformToSf(table, crs = crs, geometry.type = st_point()) - st_geometry(table_sf) <- "start_wkt" - table_sf_start <- table_sf %>% select(-end_wkt) - st_geometry(table_sf) <- "end_wkt" - table_sf_end <- table_sf %>% select(-start_wkt) - - table_sf_start <- st_transform(table_sf_start, "+proj=longlat +datum=WGS84 +no_defs") - table_sf_end <- st_transform(table_sf_end, "+proj=longlat +datum=WGS84 +no_defs") - - if (optimized) { - colors <- c("Start" = "blue", "End" = "red") - shapes <- c("Start" = 5, "End" = 3) - # ggplot2 isn't interactive! - plt <- ggplot() + - geom_sf(data = table_sf_start, aes(color = "Start"), size = 1, shape = 5) + - geom_sf(data = table_sf_end, aes(color = "End"), size = 1, shape = 3) + - labs(color = "Type") + - scale_colour_manual(values = colors) - plt - return(plt) - } - - - - - - # If we need to change design - # css_fix <- "div.info.legend.leaflet-control br {clear: both;}" - # Convert CSS to HTML - # html_fix <- htmltools::tags$style(type = "text/css", css_fix) - - - plt <- leaflet() %>% - addTiles() %>% - addProviderTiles( - "OpenStreetMap", - # give the layer a name - group = "OpenStreetMap" - ) %>% - addProviderTiles( - "Stamen.Toner", - group = "Stamen.Toner" - ) %>% - addProviderTiles( - "Stamen.Terrain", - group = "Stamen.Terrain" - ) %>% - addProviderTiles( - "Esri.WorldStreetMap", - group = "Esri.WorldStreetMap" - ) %>% - addProviderTiles( - "Wikimedia", - group = "Wikimedia" - ) %>% - addProviderTiles( - "CartoDB.Positron", - group = "CartoDB.Positron" - ) %>% - addProviderTiles( - "Esri.WorldImagery", - group = "Esri.WorldImagery" - ) %>% - addCircleMarkers(table_sf_start, - lng = st_coordinates(table_sf_start$start_wkt)[, 1], - lat = st_coordinates(table_sf_start$start_wkt)[, 2], radius = 3, color = "blue", - label = paste( - "Person_id:", - table_sf_start$person, "
", - "Trip_id:", - table_sf_start$trip_id, "
", - "main_mode:", table_sf_start$main_mode, "
", - "type:", "start", "
", - "Start activity:", - table_sf_start$start_activity_type, "
" - ) %>% lapply(htmltools::HTML) - ) %>% - addCircleMarkers(table_sf_end, - lng = st_coordinates(table_sf_end$end_wkt)[, 1], - lat = st_coordinates(table_sf_end$end_wkt)[, 2], radius = 0.15, color = "red", - label = paste( - "Person_id:", - table_sf_end$person, "
", - "Trip_id:", - table_sf_end$trip_id, "
", - "main_mode:", table_sf_end$main_mode, "
", - "type:", "end", "
", - "End activity:", - table_sf_end$end_activity_type, "
" - ) %>% lapply(htmltools::HTML) - ) %>% - addLegend( - colors = c("blue", "red"), - labels = c("Start of trip", "End of trip"), - position = "bottomleft", - title = "Type of the point", - opacity = 0.9 - ) %>% - addMiniMap() %>% - addLayersControl( - baseGroups = c( - "OpenStreetMap", "Stamen.Toner", - "Stamen.Terrain", "Esri.WorldStreetMap", - "Wikimedia", "CartoDB.Positron", "Esri.WorldImagery" - ), - # position it on the topleft - position = "topleft" - ) - - return(plt) -} - -#' Plots distribution of every type of trips(inside, outside, origin and destinating) in Pie Chart -#' -#' -#' -#' @param table tibble of trips_output (from readTripsTable()) -#' -#' @param shapeTable sf object(data.frame with geometries), can be received by using st_read(path_to_geographical_file) -#' -#' @param crs numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation -#' -#' -#' -#' @return plot with percentage of each type of trips -#' -#' @export -plotTripTypesPieChart <- function(table, shapeTable, crs) { - - # table_sf = transformToSf(table,crs = crs) - # Maybe union all this tables as 1 extended with additional column - filtered_inside <- filterByRegion(table, shapeTable, crs = crs, start.inshape = TRUE, end.inshape = TRUE) - filtered_origin <- filterByRegion(table, shapeTable, crs = crs, start.inshape = TRUE, end.inshape = FALSE) - filtered_destination <- filterByRegion(table, shapeTable, crs = crs, start.inshape = FALSE, end.inshape = TRUE) - filtered_transit <- filterByRegion(table, shapeTable, crs = crs, start.inshape = FALSE, end.inshape = FALSE) - - result <- tibble( - n = c(nrow(filtered_inside), nrow(filtered_transit), nrow(filtered_origin), nrow(filtered_destination)), - type = c("inside the shape", "outside the shape", "starting in shape", "ending in shape") - ) - - # result gives percentage representation out - result <- result %>% mutate(n = n / sum(n) * 100) - - # getthe positions - positions <- result %>% - mutate( - csum = rev(cumsum(rev(n))), - pos = n / 2 + lead(csum, 1), - pos = if_else(is.na(pos), n / 2, pos) - ) - - return(ggplot(result, aes(x = "", y = n, fill = fct_inorder(type))) + - geom_col(width = 1, col = 1) + - geom_bar(stat = "identity", width = 1) + - coord_polar("y") + - # geom_text(aes(label = round(n,digits = 1)), - # position=position_stack(vjust = 0.5), - # show.legend = FALSE,size = 4)+ - geom_label_repel( - data = positions, - aes(y = pos, label = paste0(round(n, digits = 1), "%")), - size = 4.5, nudge_x = 1, show.legend = FALSE - ) + - ggtitle("Distribution")) -} - -#' Creates BarChart of changing trip types(originating,transit etc) between 2 tables -#' and saves output to dump.output.to -#' -#' -#' -#' @param tripsTable1 tibble of trips_output (from readTripsTable(),f.e. base case) -#' -#' @param tripsTable2 tibble of trips_output (from readTripsTable(),f.e. policy case) -#' -#' @param shapeTable sf object(data.frame with geometries), can be received by using st_read(path_to_geographical_file) -#' -#' @param crs numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation -#' -#' @param dump.output.to folder that saves resulting image of BarChart -#' -#' -#' @return plot with percentage of each type of trips between 2 tables -#' -#' @export -compareTripTypesBarChart <- function(tripsTable1,tripsTable2,shapeTable,crs,dump.output.to = matsimDumpOutputDirectory){ - # table_sf = transformToSf(table,crs = crs) - # Maybe union all this tables as 1 extended with additional column - filtered_inside1 <- filterByRegion(tripsTable1, shapeTable, crs = crs, start.inshape = TRUE, end.inshape = TRUE) %>% - mutate(type = "inside",table_num = "1 table") - filtered_origin1 <- filterByRegion(tripsTable1, shapeTable, crs = crs, start.inshape = TRUE, end.inshape = FALSE) %>% - mutate(type = "start_in_shape",table_num = "1 table") - filtered_destination1 <- filterByRegion(tripsTable1, shapeTable, crs = crs, start.inshape = FALSE, end.inshape = TRUE) %>% - mutate(type = "endind_in_shape",table_num = "1 table") - filtered_transit1 <- filterByRegion(tripsTable1, shapeTable, crs = crs, start.inshape = FALSE, end.inshape = FALSE)%>% - mutate(type = "outside",table_num = "1 table") - - filtered_inside2 <- filterByRegion(tripsTable2, shapeTable, crs = crs, start.inshape = TRUE, end.inshape = TRUE) %>% - mutate(type = "inside",table_num = "2 table") - filtered_origin2 <- filterByRegion(tripsTable2, shapeTable, crs = crs, start.inshape = TRUE, end.inshape = FALSE) %>% - mutate(type = "start_in_shape",table_num = "2 table") - filtered_destination2 <- filterByRegion(tripsTable2, shapeTable, crs = crs, start.inshape = FALSE, end.inshape = TRUE) %>% - mutate(type = "endind_in_shape",table_num = "2 table") - filtered_transit2 <- filterByRegion(tripsTable2, shapeTable, crs = crs, start.inshape = FALSE, end.inshape = FALSE)%>% - mutate(type = "outside",table_num = "2 table") - - - result_table = rbind(filtered_inside1,filtered_origin1,filtered_destination1,filtered_transit1, - filtered_inside2,filtered_origin2,filtered_destination2,filtered_transit2) - - plt = ggplot(result_table, aes(x =type,fill = factor(table_num)))+ - geom_bar(position = position_dodge())+ - coord_flip() - plotly::ggplotly(plt) - - if (file.exists(dump.output.to)) { - ggsave(paste0(dump.output.to, "/tripTypeComparison.png"), plot = plt,width = 6,height = 10) - } else { - dir.create(dump.output.to) - ggsave(paste0(dump.output.to, "/tripTypeComparison.png"), plot = plt,width = 6,height = 10) - } - - return(plotly::ggplotly(plt)) - -} - -#' Plots every type of trips(inside, outside, origin and destinating) on map -#' -#' -#' -#' @param table tibble of trips_output (from readTripsTable()) -#' -#' @param shapeTable sf object(data.frame with geometries), can be received by using st_read(path_to_geographical_file) -#' -#' @param crs numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation -#' -#' @param optimized bool, by default FALSE and gives interactive plot using leaflet, if TRUE using image with ggplot -#' -#' @return plot that contains every trip with defined trip type -#' -#' @export -plotMapWithTripsType <- function(table, shapeTable, crs, optimized = FALSE) { - # table = table[1:5000,] #To make plotting faster - # table_sf = transformToSf(table,crs = crs) - # Maybe union all this tables as 1 extended with additional column - filtered_inside <- filterByRegion(table, shapeTable, crs = crs, start.inshape = TRUE, end.inshape = TRUE) - filtered_origin <- filterByRegion(table, shapeTable, crs = crs, start.inshape = TRUE, end.inshape = FALSE) - filtered_destination <- filterByRegion(table, shapeTable, crs = crs, start.inshape = FALSE, end.inshape = TRUE) - filtered_transit <- filterByRegion(table, shapeTable, crs = crs, start.inshape = FALSE, end.inshape = FALSE) - - filtered_sf_inside <- transformToSf(filtered_inside, crs = crs, geometry.type = st_multipoint()) - filtered_sf_origin <- transformToSf(filtered_origin, crs = crs, geometry.type = st_multipoint()) - filtered_sf_destination <- transformToSf(filtered_destination, crs = crs, geometry.type = st_multipoint()) - filtered_sf_transit <- transformToSf(filtered_transit, crs = crs, geometry.type = st_multipoint()) - - if (st_crs(shapeTable) == NA) { - ct_crs(shapeTable) <- crs - } - - shapeTable <- st_transform(shapeTable, crs = "+proj=longlat +datum=WGS84 +no_defs") - filtered_sf_inside <- st_transform(filtered_sf_inside, "+proj=longlat +datum=WGS84 +no_defs") - filtered_sf_origin <- st_transform(filtered_sf_origin, "+proj=longlat +datum=WGS84 +no_defs") - filtered_sf_destination <- st_transform(filtered_sf_destination, "+proj=longlat +datum=WGS84 +no_defs") - filtered_sf_transit <- st_transform(filtered_sf_transit, "+proj=longlat +datum=WGS84 +no_defs") - - if (optimized) { - colors <- c("inside" = "green", "origin" = "red", "destination" = "orange", "transit" = "blue") - shapes <- c("Start" = 5, "End" = 3) - plt <- ggplot() + - geom_sf(data = shapeTable) + - # geom_sf(data = ) - geom_sf(data = filtered_sf_inside, aes(color = "inside"), size = 3, alpha = 0.5) + - geom_sf(data = filtered_sf_origin, aes(color = "origin"), size = 3, alpha = 0.4) + - geom_sf(data = filtered_sf_destination, aes(color = "destination"), size = 3, alpha = 0.3) + - geom_sf(data = filtered_sf_transit, aes(color = "transit"), size = 2, alpha = 0.1) + - labs(color = "Type") + - scale_colour_manual(values = colors) - plt - return((plt)) - } - - # If we need to adjust design - # css_fix <- "div.info.legend.leaflet-control br {clear: both;}" - # Convert CSS to HTML - # html_fix <- htmltools::tags$style(type = "text/css", css_fix) - - - plt <- leaflet() %>% - addTiles() %>% - addProviderTiles( - "OpenStreetMap", - # give the layer a name - group = "OpenStreetMap" - ) %>% - addProviderTiles( - "Stamen.Toner", - group = "Stamen.Toner" - ) %>% - addProviderTiles( - "Stamen.Terrain", - group = "Stamen.Terrain" - ) %>% - addProviderTiles( - "Esri.WorldStreetMap", - group = "Esri.WorldStreetMap" - ) %>% - addProviderTiles( - "Wikimedia", - group = "Wikimedia" - ) %>% - addProviderTiles( - "CartoDB.Positron", - group = "CartoDB.Positron" - ) %>% - addProviderTiles( - "Esri.WorldImagery", - group = "Esri.WorldImagery" - ) %>% - addPolygons(data = shapeTable, opacity = 0.1, color = "green") %>% - addCircleMarkers(filtered_sf_inside, - lng = st_coordinates(filtered_sf_inside$wkt)[seq(1, length(filtered_sf_inside$wkt), 2), 1], - lat = st_coordinates(filtered_sf_inside$wkt)[seq(1, length(filtered_sf_inside$wkt), 2), 2], radius = 3, color = "blue", - label = paste( - "Person_id:", - filtered_sf_inside$person, "
", - "Trip_id:", - filtered_sf_inside$trip_id, "
", - "main_mode:", filtered_sf_inside$main_mode, "
", - "type:", "start", "
", - "Start activity:", - filtered_sf_inside$start_activity_type, "
" - ) %>% lapply(htmltools::HTML) - ) %>% - addCircleMarkers(filtered_sf_inside, - lng = st_coordinates(filtered_sf_inside$wkt)[seq(2, length(filtered_sf_inside$wkt), 2), 1], - lat = st_coordinates(filtered_sf_inside$wkt)[seq(2, length(filtered_sf_inside$wkt), 2), 2], radius = 3, color = "blue", - label = paste( - "Person_id:", - filtered_sf_inside$person, "
", - "Trip_id:", - filtered_sf_inside$trip_id, "
", - "main_mode:", filtered_sf_inside$main_mode, "
", - "type:", "end", "
", - "End activity:", - filtered_sf_inside$end_activity_type, "
" - ) %>% lapply(htmltools::HTML) - ) %>% - addCircleMarkers(filtered_sf_origin, - lng = st_coordinates(filtered_sf_origin$wkt)[seq(1, length(filtered_sf_inside$wkt), 2), 1], - lat = st_coordinates(filtered_sf_origin$wkt)[seq(1, length(filtered_sf_inside$wkt), 2), 2], radius = 2, color = "red", - label = paste( - "Person_id:", - filtered_sf_origin$person, "
", - "Trip_id:", - filtered_sf_origin$trip_id, "
", - "main_mode:", filtered_sf_origin$main_mode, "
", - "type:", "start", "
", - "Start activity:", - filtered_sf_origin$end_activity_type, "
" - ) %>% lapply(htmltools::HTML) - ) %>% - addCircleMarkers(filtered_sf_origin, - lng = st_coordinates(filtered_sf_origin$wkt)[seq(2, length(filtered_sf_inside$wkt), 2), 1], - lat = st_coordinates(filtered_sf_origin$wkt)[seq(2, length(filtered_sf_inside$wkt), 2), 2], radius = 2, color = "red", - label = paste( - "Person_id:", - filtered_sf_origin$person, "
", - "Trip_id:", - filtered_sf_origin$trip_id, "
", - "main_mode:", filtered_sf_origin$main_mode, "
", - "type:", "end", "
", - "End activity:", - filtered_sf_origin$end_activity_type, "
" - ) %>% lapply(htmltools::HTML) - ) %>% - addCircleMarkers(filtered_sf_destination, - lng = st_coordinates(filtered_sf_destination$wkt)[seq(1, length(filtered_sf_inside$wkt), 2), 1], - lat = st_coordinates(filtered_sf_destination$wkt)[seq(1, length(filtered_sf_inside$wkt), 2), 2], radius = 1, color = "orange", - label = paste( - "Person_id:", - filtered_sf_destination$person, "
", - "Trip_id:", - filtered_sf_destination$trip_id, "
", - "main_mode:", filtered_sf_destination$main_mode, "
", - "type:", "start", "
", - "Start activity:", - filtered_sf_destination$end_activity_type, "
" - ) %>% lapply(htmltools::HTML) - ) %>% - addCircleMarkers(filtered_sf_destination, - lng = st_coordinates(filtered_sf_destination$wkt)[seq(2, length(filtered_sf_inside$wkt), 2), 1], - lat = st_coordinates(filtered_sf_destination$wkt)[seq(2, length(filtered_sf_inside$wkt), 2), 2], radius = 1, color = "orange", - label = paste( - "Person_id:", - filtered_sf_destination$person, "
", - "Trip_id:", - filtered_sf_destination$trip_id, "
", - "main_mode:", filtered_sf_destination$main_mode, "
", - "type:", "end", "
", - "End activity:", - filtered_sf_destination$end_activity_type, "
" - ) %>% lapply(htmltools::HTML) - ) %>% - addCircleMarkers(filtered_sf_transit, - lng = st_coordinates(filtered_sf_transit$wkt)[seq(1, length(filtered_sf_inside$wkt), 2), 1], - lat = st_coordinates(filtered_sf_transit$wkt)[seq(1, length(filtered_sf_inside$wkt), 2), 2], radius = 0.15, color = "black", - label = paste( - "Person_id:", - filtered_sf_transit$person, "
", - "Trip_id:", - filtered_sf_transit$trip_id, "
", - "main_mode:", filtered_sf_transit$main_mode, "
", - "type:", "start", "
", - "Start activity:", - filtered_sf_transit$end_activity_type, "
" - ) %>% lapply(htmltools::HTML) - ) %>% - addCircleMarkers(filtered_sf_transit, - lng = st_coordinates(filtered_sf_transit$wkt)[seq(2, length(filtered_sf_inside$wkt), 2), 1], - lat = st_coordinates(filtered_sf_transit$wkt)[seq(2, length(filtered_sf_inside$wkt), 2), 2], radius = 0.15, color = "black", - label = paste( - "Person_id:", - filtered_sf_transit$person, "
", - "Trip_id:", - filtered_sf_transit$trip_id, "
", - "main_mode:", filtered_sf_transit$main_mode, "
", - "type:", "end", "
", - "End activity:", - filtered_sf_transit$end_activity_type, "
" - ) %>% lapply(htmltools::HTML) - ) %>% - addLegend( - colors = c("blue", "red", "orange", "black"), - labels = c( - "Trips inside of region", - "Trips with the end outside region", - "Trips with the start outside region", - "Trips that start and end outside region" - ), - position = "bottomleft", - title = "Type of the point", - opacity = 0.9 - ) %>% - addMiniMap() %>% - addLayersControl( - baseGroups = c( - "OpenStreetMap", "Stamen.Toner", - "Stamen.Terrain", "Esri.WorldStreetMap", - "Wikimedia", "CartoDB.Positron", "Esri.WorldImagery" - ), - # position it on the topleft - position = "topleft" - ) - - return(plt) -} - -#' Creates an instance of ODMatrix(origin/destination) in conventional form or for the simwrapper -#' -#' -#' -#' @param tripsTable table of output trips(from readTripsTable) or path to trips_output file -#' -#' @param shapePath full path to shapefile (if simwrapper TRUE, folder with shapeFile should contain also .dbf with the same name) -#' -#' @param crs numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation -#' -#' @param dump.output.to path to a folder to save csv file of ODMatrix -#' -#' @param 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 -#' -#' @param simwrapper create output in a simwrapper form if set to path of the shapefile -#' -#' @param outer logical that represent if the table should contain outside flow of the shape, it isn't -#' -#' @return tibble of origin/destination matrix -#' -#' @export -deriveODMatrix<- function(tripsTable,shapePath,crs,dump.output.to = matsimDumpOutputDirectory,simwrapper = FALSE,colnames = "numeric",outer = FALSE){ - defaultW <- getOption("warn") - options(warn = -1) - - #if tripstable given as folder/file - if(sum(class(tripsTable) %in% c("tbl_df","tbl","data.frame"))<1){ - tripsTable <- readTripsTable(tripsTable) - } - - sfTable <- transformToSf(tripsTable,crs,geometry.type = st_point()) - - shape = st_read(shapePath) - - if (st_crs(shape) == NA) { - st_crs(shape) <- crs - } - shape = st_transform(shape,crs = crs) - - sf_table <- transformToSf(tripsTable, crs = crs, geometry.type = st_point()) - - sf_start = sfTable %>% select(trip_id,start_wkt) - st_geometry(sfTable) = "end_wkt" - sf_end = sfTable %>% select(trip_id,end_wkt) - - #Get all inner intersects - sf_intersect_start = st_contains(shape,sf_start) - sf_intersect_end = st_contains(shape,sf_end) - - - if(outer == TRUE){ - #Get all outer intersects - joined_shape = st_union(shape) - - start_inside = st_contains(joined_shape,sf_start) - end_inside = st_contains(joined_shape,sf_end) - - start_outside = 1:nrow(sf_start) - end_outside = 1:nrow(sf_end) - - start_outside = start_outside[! start_outside %in% start_inside[[1]]] - - end_outside = end_outside[! end_outside %in% end_inside[[1]]] - - sf_intersect_start = append(sf_intersect_start,list(start_outside)) - sf_intersect_end = append(sf_intersect_end,list(end_outside)) - } - - # Create matrix out of it - result_tibble = as_tibble(data.frame(matrix(nrow=0,ncol=nrow(shape)))) - colnames(result_tibble) = 1:nrow(shape) - - for(i in 1:length(sf_intersect_start)){ - temp = c() - for(j in 1:length(sf_intersect_start)){ - start_i = sf_intersect_start[[i]] - end_j = sf_intersect_end[[j]] - - number_of_trips = length(intersect(start_i,end_j)) - - temp = append(temp,number_of_trips) - - } - result_tibble = rbind(result_tibble,temp) - } - - if(colnames!="numeric" & colnames %in% colnames(shape)){ - colnames(result_tibble) = shape[[colnames]] - if(outer == TRUE){ - rownames(result_tibble) = c(shape[[colnames]],"outer") - colnames(result_tibble)[length(colnames(result_tibble))] = "outer" - }else{ - rownames(result_tibble) = shape[[colnames]] - } - - }else{ - colnames(result_tibble) = sapply(1:length(sf_intersect_start),as.character) - rownames(result_tibble) = sapply(1:length(sf_intersect_start),as.character) - } - - - result_melt = melt(as.matrix(result_tibble)) - colnames(result_melt) = c("origin","destination",1) - # Generating yaml and output_files - - - - if (file.exists(dump.output.to) & simwrapper == TRUE) { - write.table(result_melt,paste0(dump.output.to,"/ODMatrix.csv"),row.names = FALSE,sep = ";") - } else if(!file.exists(dump.output.to) & simwrapper == TRUE) { - dir.create(dump.output.to) - write.table(result_melt,paste0(dump.output.to,"/ODMatrix.csv"),row.names = FALSE,sep = ";") - } else if (file.exists(dump.output.to) & simwrapper == FALSE) { - write_csv2(result_tibble,paste0(dump.output.to,"/ODMatrix.csv")) - } else { - dir.create(dump.output.to) - write_csv2(result_tibble,paste0(dump.output.to,"/ODMatrix.csv")) - } - - yaml_list <- list( - title = "OD Flow", - description = "generated by deriveODMatrix", - projection = st_crs(shape)$input, - shpFile = paste0("../",shapePath), - dbfFile = paste0("../",substr(shapePath,start = 1,stop = nchar(shapePath)-3),"dbf"), - scaleFactor = 1, - lineWidth = 50, - csvFile = "ODMatrix.csv", - idColumn = colnames(shape)[1] # at the moment idColumn of shapefile should be the first column - - ) - write_yaml(yaml_list, paste0(dump.output.to, "/viz-od-flow.yaml")) - - options(warn = defaultW) - return(result_tibble) -} - -#' Chooses a function to compare output_trips from the folders. -#' baseFolder contains all base outputs, policyFolder contains all policy outputs. -#' -#' -#' -#' @param baseFolder specifies data source folder with multiple base output_trips -#' -#' @param policyFolder specifies data source folder with multiple policy output_trips -#' -#' @param dump.output.to that saves result of all comparisons between each base and each policy. -#' For now it creates plotModalShiftBar() for the output_trips -#' -#' @return list of tibbles, list of all base and policy output_trips as tibble -#' -#' @export -compareBasePolicyOutput <- function(baseFolder,policyFolder,dump.output.to = matsimDumpOutputDirectory) { - - base_trips = list(NULL) - policy_trips = list(NULL) - for(file in list.files(baseFolder,full.names = TRUE)) - { - temp = readTripsTable(file) - if(!is.null(temp)){ - attr(temp,"table_name") = strsplit(file,'/')[[1]][-1] - if(is.null(base_trips[[1]])){ - base_trips[[1]] = temp - }else{ - base_trips = append(base_trips,list(temp)) - } - } - } - - for(file in list.files(policyFolder,full.names = TRUE)) - { - temp = readTripsTable(file) - if(!is.null(temp)){ - attr(temp,"table_name") = strsplit(file,'/')[[1]][-1] - if(is.null(policy_trips[[1]])){ - policy_trips[[1]] = temp - }else{ - policy_trips = append(policy_trips,list(temp)) - } - } - } - i = 0; - - print(dump.output.to) - if (!file.exists(dump.output.to)) { - dir.create(dump.output.to) - } - for(base in base_trips){ - - for(policy in policy_trips){ - print(paste0(i," comparison")) - name = paste0(i,"_",attr(base,"table_name"),"--",attr(policy,"table_name")) - plotModalShiftBar(base, - policy, - dump.output.to = dump.output.to, - output.name = name) - - i=i+1 - } - } - invisible(list(base = base_trips,policy = policy_trips)) -} -#' Chooses a function to compare output_trips from the folders. -#' baseFolder contains all base outputs, policyFolder contains all policy outputs. -#' -#' -#' -#' @param baseFolder specifies data source folder with multiple base output_trips -#' -#' @param policyFolder specifies data source folder with multiple policy output_trips -#' -#' @param shapeFilePath specifies shapeFile used for comparison -#' @param crs numeric of EPSG code or proj4string, can be found in network/config file from output directory of MATSim simulation -#' @param dump.output.to that saves result of all comparisons between each base and each policy. -#' For now it creates plotModalShiftBar() for the output_trips -#' -#' @return list of tibbles, list of all base and policy output_trips as tibble -#' -#' @export -compareBasePolicyShapeOutput <- function(baseFolder,policyFolder,shapeFilePath,crs,dump.output.to = matsimDumpOutputDirectory) { - - base_trips = list(NULL) - policy_trips = list(NULL) - shape = st_read(shapeFilePath) - for(file in list.files(baseFolder,full.names = TRUE)) - { - temp = readTripsTable(file) - if(!is.null(temp)){ - attr(temp,"table_name") = strsplit(file,'/')[[1]][-1] - if(is.null(base_trips[[1]])){ - base_trips[[1]] = temp - }else{ - base_trips = append(base_trips,list(temp)) - } - } - } - - for(file in list.files(policyFolder,full.names = TRUE)) - { - temp = readTripsTable(file) - if(!is.null(temp)){ - attr(temp,"table_name") = strsplit(file,'/')[[1]][-1] - if(is.null(policy_trips[[1]])){ - policy_trips[[1]] = temp - }else{ - policy_trips = append(policy_trips,list(temp)) - } - } - } - i = 0; - - if (!file.exists(dump.output.to)) { - dir.create(dump.output.to) - } - for(base in base_trips){ - - for(policy in policy_trips){ - print(paste0(i," comparison")) - plotModalShiftBar(base, - policy, - crs, - dump.output.to = paste0(dump.output.to,"/",i,"_",attr(base,"table_name"),"--",attr(policy,"table_name")) ) - compareTripTypesBarChart(base,policy,shape,crs,dump.output.to = paste0(dump.output.to,"/",i,"_",attr(base,"table_name"),"--",attr(policy,"table_name"))) - i=i+1 - - } - } - invisible(list(base = base_trips,policy = policy_trips)) -} - - - -#' Reads an coordinate referenec system of MATSim output directory -#' from output_config.xml -#' -#' @param folder specifies path to find config -#' -#' -#' @return code of coordinate reference system -#' -#' @export -getCrsFromConfig <- function(folder) { - - if (grepl("output_config.xml$", folder) == TRUE) - { - config <- read_xml(folder) - - param_nodes = xml_find_all(config,"//param") - - coord_node = param_nodes[xml_attr(param_nodes,"name") == "coordinateSystem"] - - coord_system = xml_attr(coord_node,"value") - return(coord_system) - } - - files <- list.files(folder, full.names = TRUE) - # Read from global/local directory - # output_config.xml is contained as output_trips.csv.gz - if (length(grep("output_config.xml$", files)) != 0) { - config <- read_xml(files[grep("output_config.xml$", files)]) - - param_nodes = xml_find_all(config,"//param") - - coord_node = param_nodes[xml_attr(param_nodes,"name") == "coordinateSystem"] - - coord_system = xml_attr(coord_node,"value") - return(coord_system) - } - return(NA) -} - - -appendDistanceCategory <- function(tripsTable){ - modes = levels(factor(tripsTable$main_mode)) - - #This is a very bad way to do that, but I see no other way to get it done - #Also filtering table into a new doesn't creates new objects in memory, so it works fast - tripsTable_05km = tripsTable %>% filter(traveled_distance<=1000) %>% mutate(dist_cat = "0-1km") - #tripsTable_1km = tripsTable %>% filter(traveled_distance>500 & traveled_distance<=1000 ) %>% mutate(dist_cat = "0.5-1km") - tripsTable_2km = tripsTable %>% filter(traveled_distance>1000 & traveled_distance<=2000) %>% mutate(dist_cat = "1-2km") - tripsTable_5km = tripsTable %>% filter(traveled_distance>2000 & traveled_distance<=5000) %>% mutate(dist_cat = "2-5km") - tripsTable_10km = tripsTable %>% filter(traveled_distance>5000 & traveled_distance<=10*1000) %>% mutate(dist_cat = "5-10km") - tripsTable_20km = tripsTable %>% filter(traveled_distance>10*1000 & traveled_distance<=20*1000) %>% mutate(dist_cat = "10-20km") - tripsTable_50km = tripsTable %>% filter(traveled_distance>20*1000 & traveled_distance<=50*1000) %>% mutate(dist_cat = "20-50km") - tripsTable_100km = tripsTable %>% filter(traveled_distance>50*1000 & traveled_distance<=100*1000) %>% mutate(dist_cat = "50-100km") - tripsTable_100pluskm = tripsTable %>% filter(traveled_distance>100*1000) %>% mutate(dist_cat = "> 100km") - - tripsTable_result = rbind(tripsTable_05km, - #tripsTable_1km, - tripsTable_2km, - tripsTable_5km, - tripsTable_10km, - tripsTable_20km, - tripsTable_50km, - tripsTable_100km, - tripsTable_100pluskm) - - tripsTable_result$dist_cat = factor(tripsTable_result$dist_cat,levels = c("0-1km","1-2km","2-5km","5-10km","10-20km","20-50km","50-100km","> 100km")) - return(tripsTable_result) -} diff --git a/docs/404.html b/docs/404.html index d882c2d..3d712f7 100644 --- a/docs/404.html +++ b/docs/404.html @@ -7,10 +7,10 @@ Page not found (404) • matsim - - + + - + GNU General Public License • matsimGNU General Public License • matsim @@ -10,7 +10,7 @@ matsim - 0.1.8 + 0.2.0 + + + + + +
+ + + + +
+
+ + + +

The data used in this example project can be found on the [public +repository] (https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/) +from VSP Berlin. There you can also find other MATSim scenarios.

+
+

Introduction +

+

This vignette offers an example workflow from MATSim output to +thematic plots and maps. For a general overview of the package and its +structure please read the introduction.

+

A short recap however: functions are divided into four categories and +start with a respective prefix. Read_, process_, plot_ or compare_ and +in the future simwrapper_. To better understand the naming conventions +(for example to create your own functions) consult this vignette +[LINK].

+
+
+

Installation +

+

MATSim R is not yet available at CRAN, so to install MATSim R using +github, use the following code.

+
+devtools::install_github("matsim-vsp/matsim-r")
+
+
+

Loading the package +

+

Once installed, you can load the MATSim R package using the library() +function:

+ +
+
+

Loading data +

+

The data we’ll use in this example project is the result of a Leipzig +run which you can find under the following link. (https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/leipzig/projects/namav/base-case/)

+

If you want to follow along, download a copy of the folder.

+

To start, we will load the output_trips.csv.gz file. It is a zipped +file, but that is okay, the functions can handle that. We will also load +a shape file, which can be found here. (https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/leipzig/leipzig-v1.1/input/shp/)

+
+ trips_file_path <- "paste_file_path_here"
+ 
+ # if you don't want to immediately load the whole file, the function read_output_trips has the option to only load the first n lines 
+ output_trips <- read_output_trips(trips_file_path, n_max = 5000)
+
+
+

Plot a modal split +

+

There are two functions to calculate and plot modal splits: +plot_mainmode_piechart() and +plot_mainmode_piechart(). As the name suggests the first +one plots the modal split as a pie chart and the second one as a bar +chart. To do this, they use the processing function +process_get_mainmode_distribution() and plot the resulting +table. The processing function can also be used on its own to just get +the raw numbers.

+

We are going to plot a bar chart:

+
+ plot_mainmode_barchart(output_trips)
+

The resulting bar chart looks like this:

+
+

Leipzig modal split

+
+
+
+

Spatial filter +

+

In a next step we want to spatially filter our data. So far we have +been looking at all the trips in the simulation, now we want to focus on +those that touch our project area.

+

To do this we can use the function +process_filter_by_shape() and the shape file we’ve already +loaded. The parameter crs is the coordinate system number +and the spatial_type describes the way the trips interact with the +project area. The four options are inside, outside, originating and +destinating. In this case we will look at the originating trips.

+
+trips_originating <- process_filter_by_shape(output_trips, leipzig_shp, crs = 25832, spatial_type = "originating" )
+

Using plot_mainmode_barchart() on the 507 originating +trips, results in the following chart:

+
+

Leipzig modal split - trips originating in project +area

+
+
+
+

Comparison plots +

+

In a next step we will compare the modal split of this base model +with the modal split of a scenario. To do this we need to load the +output_trips file from a scenario, e.g. this one. https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/leipzig/projects/namav/drt-outskirts/

+
+#loading the scenario data
+output_trips_scenario <- read_output_trips(trips_file_scenario_path, n_max = 5000)
+
+#filtering the scenario data
+trips_scenario_originating <- process_filter_by_shape(output_trips_scenario, leipzig_shp, crs = 25832, spatial_type = "originating")
+
+#creating the comparison plot
+plot_compare_mainmode_barchart(trips_originating, trips_scenario_originating)
+

The resulting plot looks like this: Leipzig modal split comparison

+
+
+

Maps +

+

The package also allows the plotting of spatial data. As an example +we can plot the trips originating in the project area to see where they +end.

+
+plot_map_trips(trips_originating, crs = 25832)
+

The result is an interactive map using leaflet, showing the places of +origin in blue and the destinations in red. (The following image is a +screenshot)

+
+

Leipzig - originating trips

+
+
+
+
+ + + +
+ + + +
+
+ + + + + + + diff --git a/docs/articles/Introduction.html b/docs/articles/Introduction.html new file mode 100644 index 0000000..7856233 --- /dev/null +++ b/docs/articles/Introduction.html @@ -0,0 +1,254 @@ + + + + + + + + +Introduction to MATSim R Library: analyzing transport simulations • matsim + + + + + + + + + + Skip to contents + + +
+ + + + +
+
+ + + + +
+

Introduction +

+

Welcome to the MATSim R package! MATSim R is an R package designed +for data processing and visualization and provides a wide range of +functions to create adjustable plots from processed data. This vignette +will give you an overview of the structure of the package and quickly +guide you through the process of creating plots using the functions +provided by the library.

+
+
+

Overall concept +

+

The purpose of this package is to provide a comprehensive set of +tools to efficiently analyze the output of MATSim runs. The package +primarily processes output data stored in CSV and XML files, especially +the so called “output_trips”, “legs” and “persons” files. By adhering to +this standardized naming convention, the package offers a streamlined +functionality for reading, processing, plotting and YAML file creation +for use in Simwrapper. XXXX LINK TO SIMWRAPPER GITHUB xxxx

+
+

Data flow and concept of matsim r package

+
+

The package is organized into four categories, each serving a +specific purpose:

+

Reading Functions: These functions begin with the +prefix “read_” and are designed to read and import the simulation +output. Field types are automatically set and a tibble is created.

+

Processing Functions: Functions with the prefix +“process_” form the core of the package’s data manipulation +capabilities. Users can apply a variety of transformations and +calculations to the loaded tibbles, allowing for advanced processing and +analysis tailored to their specific needs. Spatial input/output is also +supported, enabling users to manipulate and analyze the data on a +spatial level as well.

+

Plotting Functions: The plotting functions with the +prefix “plot_” enable users to create visualizations based on the +processed output data. These functions offer a range of plotting +options, allowing users to explore patterns, trends, and relationships +within the simulation results. The plotting functions encompass two +additional subcategories, namely mapping and +comparing. Within the mapping subcategory, +users can generate visualizations that overlay simulation results onto +geographical maps, providing insights into spatial patterns and +distributions. The comparing subcategory offers tools to compare +different simulation outputs, allowing analysis and understanding of +variations between scenarios or data sets.

+

Simwrapper: The simwrapper category is a specialized +group within the package that facilitates plotting using YAML files in +Simwrapper. This feature allows users to define complex plots and +visualizations in the YAML format, providing a convenient and efficient +way to generate custom visual representations of their simulation +data.

+

With this structure MATSim R aims to simplify the analysis of MATSim +runs. It provides users with an intuitive workflow, from reading and +processing the simulation output to generating informative plots and +leveraging the power of YAML-based configurations.

+
+
+

Installation +

+

MATSim R is not yet available at CRAN, so to install MATSim R using +github, you can use the following code:

+
+devtools::install_github("matsim-vsp/matsim-r")
+

However if you want to use a specific branch it can be specified like +so:

+
+devtools::install_github("matsim-vsp/matsim-r", ref = "{name of the branch}")
+
+
+

Loading the package +

+

Once installed, you can load the MATSim R package using the library() +function:

+ +
+
+

Loading Data +

+

The first step in analyzing your transport simulations is to load the +output data into your R environment. MATSim provides several functions +with the “read_” prefix for this purpose. Let’s take a look at how you +can load your simulation output stored in a CSV file:

+
+# Specify the file path to your simulation output. 
+# It can be a directory path or direct path to a file
+output_file <- "path/to/your/output_trips.csv"
+
+# Use the read_csv_trips() function to read the simulation data
+trips_data <- read_output_trips(output_file)
+

You can now proceed to explore and analyze the loaded data.

+
+
+

Data Processing +

+

MATSim R offers a range of processing functions, prefixed with +“process_”, to manipulate and transform your simulation data. These +functions allow you to perform various operations, such as filtering, +aggregating, and calculating additional metrics. Let’s see an example of +applying a transformation to our loaded data: XXXX IS THE EXAMPLE +CORRECT? - filter by shape?? XXXX

+
+# Filter the trips data to include only weekday trips
+weekday_trips <- process_filter_by_shape(trips_data)
+
+# Calculate the average trip duration
+average_duration <- process_get_travelwaittime_by_mainmode(weekday_trips)
+

Feel free to explore the different processing functions available in +the package to suit your specific analysis requirements.

+
+
+

Plotting +

+

Visualizing your simulation data is crucial for gaining insights and +effectively communicating your findings. MATSim R provides a wide range +of plotting functions to help you create informative visualizations. +Let’s create a scatter plot to visualize the relationship between trip +distance and trip duration:

+
+# Create a scatter plot of trip distance among different main modes
+plot_distance_by_mainmode_barchart(trips_data, x = "distance", y = "duration")
+

You can customize the plot appearance and explore other plot types, +such as line plots, bar charts, and spatial maps, using the various +plotting functions provided by MATSim R.

+
+
+

Advanced Features (still in development) +

+
    +
  • still in development -
  • +
+
+
+

Conclusion +

+

In this vignette, we introduced you to the MATSim R package, designed +specifically for analyzing MATSim outputs. We hope that you’ll have a +great experience using this library and we are glad to receive feedback +at https://github.com/matsim-vsp/matsim-r/tree/master +or at mail

+

For more details and specific usage examples, refer to the package +documentation and other vignettes available. Happy analyzing with MATSim +R!

+
+
+
+ + + +
+ + + +
+
+ + + + + + + diff --git a/docs/articles/Leipzig_modal_split.png b/docs/articles/Leipzig_modal_split.png new file mode 100644 index 0000000..be5e6b5 Binary files /dev/null and b/docs/articles/Leipzig_modal_split.png differ diff --git a/docs/articles/Leipzig_modalsplit_comparison.png b/docs/articles/Leipzig_modalsplit_comparison.png new file mode 100644 index 0000000..2de768b Binary files /dev/null and b/docs/articles/Leipzig_modalsplit_comparison.png differ diff --git a/docs/articles/Leipzig_modalsplit_originating.png b/docs/articles/Leipzig_modalsplit_originating.png new file mode 100644 index 0000000..32000b6 Binary files /dev/null and b/docs/articles/Leipzig_modalsplit_originating.png differ diff --git a/docs/articles/Namings.html b/docs/articles/Namings.html new file mode 100644 index 0000000..10749ab --- /dev/null +++ b/docs/articles/Namings.html @@ -0,0 +1,347 @@ + + + + + + + + +Namings • matsim + + + + + + + + + + Skip to contents + + +
+ + + + +
+
+ + + +
+

Overview +

+

All function names are built using the same naming template. +Functions start with a specific verb (e.g. read, plot, process) that +describes their main usage. 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.

+
    +
  • plot
  • +
  • read
  • +
  • process
  • +
+

{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:

+
    +
  • compare
  • +
  • map
  • +
+

For processing functions:

+
    +
  • get
  • +
  • rename
  • +
  • append
  • +
  • filter
  • +
  • convert
  • +
+

[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 +

+
    +
  • plot_arrtime_by_act +
      +
    • plot: Indicates that this function is used to plot data.
    • +
    • arrtime: Refers to “Arrival Time,” which is the key aspect being +visualized.
    • +
    • by_act: Indicates that the plot is grouped by “Activity.”
    • +
    +
  • +
  • plot_compare_count_by_spatialcat_barchart +
      +
    • plot: Indicates that this function is used to plot data.
    • +
    • compare_count: Refers to comparing the count of trips.
    • +
    • by_spatialcat: Indicates that the comparison is based on “Spatial +Categories.”
    • +
    • barchart: Specifies the type of plot used for visualization.
    • +
    +
  • +
  • plot_compare_distcat_by_mainmode_barchart +
      +
    • plot: Indicates that this function is used to plot data.
    • +
    • compare_distcat: Refers to comparing the distribution of trips based +on “Distance Categories.”
    • +
    • by_mainmode: Indicates that the comparison is based on different +“Main Modes.”
    • +
    • barchart: Specifies the type of plot used for visualization.
    • +
    +
  • +
  • plot_compare_mainmode_barchart +
      +
    • plot: Indicates that this function is used to plot data.
    • +
    • compare_mainmode: Refers to comparing different “Main Modes.”
    • +
    • barchart: Specifies the type of plot used for visualization.
    • +
    +
  • +
  • plot_compare_mainmode_sankey +
      +
    • plot: Indicates that this function is used to plot data.
    • +
    • compare_mainmode: Refers to comparing different “Main Modes.”
    • +
    • sankey: Specifies the type of plot used for visualization, which is +a “Sankey Diagram.”
    • +
    +
  • +
  • plot_compare_travelwaittime_by_mainmode +
      +
    • plot: Indicates that this function is used to plot data.
    • +
    • compare_travelwaittime: Refers to comparing the “Travel Time” and +“Wait Time.”
    • +
    • by_mainmode: Indicates that the comparison is based on different +“Main Modes.”
    • +
    +
  • +
  • plot_compare_travelwaittime_by_mainmode_barchart +
      +
    • plot: Indicates that this function is used to plot data.
    • +
    • compare_travelwaittime: Refers to comparing the “Travel Time” and +“Wait Time.”
    • +
    • by_mainmode: Indicates that the comparison is based on different +“Main Modes.”
    • +
    • barchart: Specifies the type of plot used for visualization.
    • +
    +
  • +
  • plot_deptime_by_act +
      +
    • plot: Indicates that this function is used to plot data.
    • +
    • deptime: Refers to “Departure Time,” which is the key aspect being +visualized.
    • +
    • by_act: Indicates that the plot is segmented or grouped by +“Activity.”
    • +
    +
  • +
  • plot_distance_by_mainmode_barchart +
      +
    • plot: Indicates that this function is used to plot data.
    • +
    • distance: Refers to “Distance,” which is the key aspect being +visualized.
    • +
    • by_mainmode: Indicates that the plot is segmented or grouped by +different “Main Modes.”
    • +
    • barchart: Specifies the type of plot used for visualization.
    • +
    +
  • +
  • plot_distance_by_spatialcat_barchart +
      +
    • plot: Indicates that this function is used to plot data.
    • +
    • distance: Refers to “Distance,” which is the key aspect being +visualized.
    • +
    • by_spatialcat: Indicates that the plot is segmented or grouped by +“Spatial Categories.”
    • +
    • barchart: Specifies the type of plot used for visualization.
    • +
    +
  • +
  • plot_distcat_by_mainmode_barchart +
      +
    • plot: Indicates that this function is used to plot data.
    • +
    • distcat: Refers to “Distance Categories,” which is the key aspect +being visualized.
    • +
    • by_mainmode: Indicates that the plot is segmented or grouped by +different “Main Modes.”
    • +
    • barchart: Specifies the type of plot used for visualization.
    • +
    +
  • +
  • plot_mainmode_barchart +
      +
    • plot: Indicates that this function is used to plot data.
    • +
    • mainmode: Refers to “Main Modes,” which is the key aspect being +visualized.
    • +
    • barchart: Specifies the type of plot used for visualization.
    • +
    +
  • +
  • plot_mainmode_piechart +
      +
    • plot: Indicates that this function is used to plot data.
    • +
    • mainmode: Refers to “Main Modes,” which is the key aspect being +visualized.
    • +
    • piechart: Specifies the type of plot used for visualization.
    • +
    +
  • +
  • plot_map_trips +
      +
    • plot: Indicates that this function is used to plot data.
    • +
    • map_trips: Refers to “Mapping of Trips,” which is the key aspect +being visualized.
    • +
    +
  • +
  • process_append_distcat +
      +
    • process: Indicates that this function is used to process data.
    • +
    • append_distcat: Refers to appending “Distance Categories” to the +trips_table.
    • +
    +
  • +
  • process_append_spatialcat +
      +
    • process: Indicates that this function is used to process data.
    • +
    • append_spatialcat: Refers to appending “Spatial Categories” to the +trips_table.
    • +
    +
  • +
  • process_convert_table_to_sf +
      +
    • process: Indicates that this function is used to process data.
    • +
    • convert_table_to_sf: Refers to converting the trips_table to a +spatial data frame (sf).
    • +
    +
  • +
  • process_convert_time +
      +
    • process: Indicates that this function is used to process data.
    • +
    • convert_time: Refers to converting time data in the trips_table to a +specified format.
    • +
    +
  • +
  • process_filter_by_shape +
      +
    • process: Indicates that this function is used to process data.
    • +
    • filter_by_shape: Refers to filtering trips in the trips_table based +on a shape.
    • +
    +
  • +
+
+
+
+ + + +
+ + + +
+
+ + + + + + + diff --git a/docs/articles/dataflow.png b/docs/articles/dataflow.png new file mode 100644 index 0000000..02f8cf1 Binary files /dev/null and b/docs/articles/dataflow.png differ diff --git a/docs/articles/index.html b/docs/articles/index.html new file mode 100644 index 0000000..930b158 --- /dev/null +++ b/docs/articles/index.html @@ -0,0 +1,80 @@ + +Articles • matsim + Skip to contents + + +
+
+
+ + +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/authors.html b/docs/authors.html index f200719..29685d7 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -1,5 +1,5 @@ -Authors and Citation • matsimAuthors and Citation • matsim @@ -10,7 +10,7 @@ matsim - 0.1.8 + 0.2.0 - - - - - -
-
-
- -
-

Takes Table trips_output (from readTripsTable()), -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')

-
- -
-

Usage

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

Arguments

-
tripsTable1
-

tible of trips_output (from readTripsTable())

- - -
tripsTable2
-

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

- -
-
-

Value

- - -

Bar Chart plot of average time spent on travel/wait

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/compareBasePolicyOutput.html b/docs/reference/compareBasePolicyOutput.html deleted file mode 100644 index e871395..0000000 --- a/docs/reference/compareBasePolicyOutput.html +++ /dev/null @@ -1,105 +0,0 @@ - -Chooses a function to compare output_trips from the folders. -baseFolder contains all base outputs, policyFolder contains all policy outputs. — compareBasePolicyOutput • matsim - Skip to contents - - -
-
-
- -
-

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

-
- -
-

Usage

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

Arguments

-
baseFolder
-

specifies data source folder with multiple base output_trips

- - -
policyFolder
-

specifies data source folder with multiple policy output_trips

- - -
dump.output.to
-

that saves result of all comparisons between each base and each policy. -For now it creates plotModalShiftBar() for the output_trips

- -
-
-

Value

- - -

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

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/compareBasePolicyShapeOutput.html b/docs/reference/compareBasePolicyShapeOutput.html deleted file mode 100644 index 493410e..0000000 --- a/docs/reference/compareBasePolicyShapeOutput.html +++ /dev/null @@ -1,115 +0,0 @@ - -Chooses a function to compare output_trips from the folders. -baseFolder contains all base outputs, policyFolder contains all policy outputs. — compareBasePolicyShapeOutput • matsim - Skip to contents - - -
-
-
- -
-

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

-
- -
-

Usage

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

Arguments

-
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

- - -
crs
-

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

- - -
dump.output.to
-

that saves result of all comparisons between each base and each policy. -For now it creates plotModalShiftBar() for the output_trips

- -
-
-

Value

- - -

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

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/compareModalDistanceDistribution.html b/docs/reference/compareModalDistanceDistribution.html deleted file mode 100644 index 83bfb2b..0000000 --- a/docs/reference/compareModalDistanceDistribution.html +++ /dev/null @@ -1,122 +0,0 @@ - -Bar Chart with distance travelled on x-axis and difference of number of trips on y-axis — compareModalDistanceDistribution • matsim - Skip to contents - - -
-
-
- -
-

Takes 2 Tables trips_output (from readTripsTable()), -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')

-
- -
-

Usage

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

Arguments

-
tripsTable1
-

tible of trips_output (from readTripsTable()), number of trips of this table will be extracted from number of trips of tripsTable1

- - -
tripsTable2
-

tible of trips_output (from readTripsTable()), from number of trips of this table number of trips of tripsTable1 will be extracted

- - -
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

- -
-
-

Value

- - -

Bar Chart plot of count of trips among distance travelled

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/createCountScatterPlot.html b/docs/reference/createCountScatterPlot.html index c4b28f0..0d87f90 100644 --- a/docs/reference/createCountScatterPlot.html +++ b/docs/reference/createCountScatterPlot.html @@ -1,12 +1,12 @@ Creates a Via-Style scatterplot for each run — createCountScatterPlot • matsimCreates a Via-Style scatterplot for each run — createCountScatterPlot • matsimCreates an instance of ODMatrix(origin/destination) in conventional form or for the simwrapper — deriveODMatrix • matsim - Skip to contents - - -
-
-
- -
-

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

-
- -
-

Usage

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

Arguments

-
tripsTable
-

table of output trips(from readTripsTable) or path to trips_output file

- - -
shapePath
-

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

- - -
crs
-

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

- - -
dump.output.to
-

path to a folder to save csv file of ODMatrix

- - -
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

- -
-
-

Value

- - -

tibble of origin/destination matrix

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/figures/dataflow.png b/docs/reference/figures/dataflow.png new file mode 100644 index 0000000..02f8cf1 Binary files /dev/null and b/docs/reference/figures/dataflow.png differ diff --git a/docs/reference/filterByRegion.html b/docs/reference/filterByRegion.html deleted file mode 100644 index d2ab757..0000000 --- a/docs/reference/filterByRegion.html +++ /dev/null @@ -1,129 +0,0 @@ - -Filtering of trips_table(from readTripsTable) depending on how they located in given shape — filterByRegion • matsim - Skip to contents - - -
-
-
- -
-

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

-
- -
-

Usage

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

Arguments

-
tripsTable
-

tibble of trips_output (from readTripsTable())

- - -
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

- - -
start.inshape
-

bool, defines trips to conclude (see Description)

- - -
end.inshape
-

bool, defines trips to conclude (see Description)

- -
-
-

Value

- - -

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

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/generateXYHexagonYaml.html b/docs/reference/generateXYHexagonYaml.html index 7050b32..a789568 100644 --- a/docs/reference/generateXYHexagonYaml.html +++ b/docs/reference/generateXYHexagonYaml.html @@ -1,5 +1,5 @@ -Creates/adds XY hexagon definition of output trips to a summary dashboard — generateXYHexagonYaml • matsimCreates/adds XY hexagon definition of output trips to a summary dashboard — generateXYHexagonYaml • matsim @@ -10,7 +10,7 @@ matsim - 0.1.8 + 0.2.0 - - - - - -
-
-
- -
-

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

-
- -
-

Usage

-
getCrsFromConfig(folder)
-
- -
-

Arguments

-
folder
-

specifies path to find config

- -
-
-

Value

- - -

code of coordinate reference system

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/index.html b/docs/reference/index.html index 2de7a3c..aaa5844 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -1,5 +1,5 @@ -Function reference • matsimFunction reference • matsim @@ -10,7 +10,7 @@ matsim - 0.1.8 + 0.2.0 + + + + + +
+
+
+ +
+

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

+
+ +
+

Usage

+
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())
+
+ +
+

Arguments

+
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
+

table of output trips(from read_output_trips) or path to trips_output file

+ + +
unite.columns
+

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

+ + +
united.name
+

if columns were united, you can specify name for the resulting column in plot

+ + +
dump.output.to
+

path to a folder to save csv file of ODMatrix

+ + +
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

+ + +
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

+ + +

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)

+
+
+

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

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/mergeCountsAndLinks.html b/docs/reference/mergeCountsAndLinks.html index 8b2b047..26a1f1f 100644 --- a/docs/reference/mergeCountsAndLinks.html +++ b/docs/reference/mergeCountsAndLinks.html @@ -1,7 +1,7 @@ -Load Counts, a limited number of Linkstats and Network links as joined tibble into memory — mergeCountsAndLinks • matsimJoin counts and linkstats to the network, creating a tibble into memory — mergeCountsAndLinks • matsim @@ -12,7 +12,7 @@ matsim - 0.1.8 + 0.2.0 - - - - - -
-
-
- -
-

Takes Table trips_output (from readTripsTable()), -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')

-
- -
-

Usage

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

Arguments

-
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 activity types 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

- -
-
-

Value

- - -

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

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/plotArrivalTimesPerTripPurpose.html b/docs/reference/plotArrivalTimesPerTripPurpose.html deleted file mode 100644 index 2e4c49a..0000000 --- a/docs/reference/plotArrivalTimesPerTripPurpose.html +++ /dev/null @@ -1,120 +0,0 @@ - -This function plots the number of trips ending per trip purpose over time. The trip purpose corresponds to the activity type of the destination activity of a given trip. -Thus, the y-axis of the plot can also be interpreted as the number of activities starting (based on the assumption that trip end time = activity start time). — plotArrivalTimesPerTripPurpose • matsim - Skip to contents - - -
-
-
- -
-

Takes Table trips_output (from readTripsTable()), -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')

-
- -
-

Usage

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

Arguments

-
tripsTable
-

tibble of trips_output (from readTripsTable())

- - -
unite.columns
-

vector of character strings, that represent patterns of columns to be united, changes name of all activity types 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 plot

- - -
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

- -
-
-

Value

- - -

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

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/plotAverageTravelWait.html b/docs/reference/plotAverageTravelWait.html deleted file mode 100644 index 63af72a..0000000 --- a/docs/reference/plotAverageTravelWait.html +++ /dev/null @@ -1,117 +0,0 @@ - -Bar Chart with main_mode on x-axis and average travel/wait time on y-axis — plotAverageTravelWait • matsim - Skip to contents - - -
-
-
- -
-

Takes Table trips_output (from readTripsTable()), -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')

-
- -
-

Usage

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

Arguments

-
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

- -
-
-

Value

- - -

Bar Chart plot of average time spent on travel/wait

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/plotDepartureTimesPerTripPurpose.html b/docs/reference/plotDepartureTimesPerTripPurpose.html deleted file mode 100644 index 834f41f..0000000 --- a/docs/reference/plotDepartureTimesPerTripPurpose.html +++ /dev/null @@ -1,117 +0,0 @@ - -This function plots the number of trips starting per trip purpose over time. The trip purpose corresponds to the activity type of the destination activity of a given trip. — plotDepartureTimesPerTripPurpose • matsim - Skip to contents - - -
-
-
- -
-

Takes Table trips_output (from readTripsTable()), -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')

-
- -
-

Usage

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

Arguments

-
tripsTable
-

tibble of trips_output (from readTripsTable())

- - -
unite.columns
-

vector of character strings, that represent patterns of columns to be united, changes name of all activity types 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 plot

- - -
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

- -
-
-

Value

- - -

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

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/plotMapWithTrips.html b/docs/reference/plotMapWithTrips.html deleted file mode 100644 index 1c743cc..0000000 --- a/docs/reference/plotMapWithTrips.html +++ /dev/null @@ -1,134 +0,0 @@ - -Plots result of filtered trips on the map (from shape) — plotMapWithTrips • matsim - Skip to contents - - -
-
-
- -
-

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

-
- -
-

Usage

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

Arguments

-
table
-

tibble of trips_output (from readTripsTable())

- - -
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

- - -
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

- -
-
-

Value

- - -

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

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/plotMapWithTripsType.html b/docs/reference/plotMapWithTripsType.html deleted file mode 100644 index fa02b23..0000000 --- a/docs/reference/plotMapWithTripsType.html +++ /dev/null @@ -1,98 +0,0 @@ - -Plots every type of trips(inside, outside, origin and destinating) on map — plotMapWithTripsType • matsim - Skip to contents - - -
-
-
- -
-

Plots every type of trips(inside, outside, origin and destinating) on map

-
- -
-

Usage

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

Arguments

-
table
-

tibble of trips_output (from readTripsTable())

- - -
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

- - -
optimized
-

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

- -
-
-

Value

- - -

plot that contains every trip with defined trip type

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/plotModalDistanceDistribution.html b/docs/reference/plotModalDistanceDistribution.html deleted file mode 100644 index 784082f..0000000 --- a/docs/reference/plotModalDistanceDistribution.html +++ /dev/null @@ -1,117 +0,0 @@ - -Bar Chart with distance travelled on x-axis and number of trips on y-axis — plotModalDistanceDistribution • matsim - Skip to contents - - -
-
-
- -
-

Takes Table trips_output (from readTripsTable()), -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')

-
- -
-

Usage

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

Arguments

-
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

- -
-
-

Value

- - -

Bar Chart plot of count of trips among distance travelled

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/plotModalShiftBar.html b/docs/reference/plotModalShiftBar.html deleted file mode 100644 index 4dd9980..0000000 --- a/docs/reference/plotModalShiftBar.html +++ /dev/null @@ -1,123 +0,0 @@ - -Plot bar chart diagram of transport mode changes — plotModalShiftBar • matsim - Skip to contents - - -
-
-
- -
-

Takes two trips_table (from readTripsTable), and collects -changes between transport mode distribution of these tables -to make bar chart diagram with dodging positioning from this data

-
- -
-

Usage

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

Arguments

-
tripsTable1
-

tible of trips_output (from readTripsTable())

- - -
tripsTable2
-

tible of trips_output (from readTripsTable())

- - -
unite.columns
-

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

- - -
united.name
-

if columns were united, you can specify name for the resulting column in plot

- - -
dump.output.to
-

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

- -
-
-

Value

- - -

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

-
-
-

Details

-

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

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/plotModalShiftSankey.html b/docs/reference/plotModalShiftSankey.html deleted file mode 100644 index a6aecf2..0000000 --- a/docs/reference/plotModalShiftSankey.html +++ /dev/null @@ -1,127 +0,0 @@ - -Plot alluvial/sankey diagram of transport mode changes — plotModalShiftSankey • matsim - Skip to contents - - -
-
-
- -
-

Takes two trips_table (from readTripsTable), and collects -changes between transport mode distribution of these tables -to make alluvial diagram from this data

-
- -
-

Usage

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

Arguments

-
tripsTable1
-

tible of trips_output (from readTripsTable())

- - -
tripsTable2
-

tible of trips_output (from readTripsTable())

- - -
show.onlyChanges
-

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

- - -
unite.columns
-

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

- - -
united.name
-

if columns were united, you can specify name for the resulting column in plot

- - -
dump.output.to
-

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

- -
-
-

Value

- - -

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

-
-
-

Details

-

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

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/plotModalSplitBarChart.html b/docs/reference/plotModalSplitBarChart.html deleted file mode 100644 index 62604ca..0000000 --- a/docs/reference/plotModalSplitBarChart.html +++ /dev/null @@ -1,120 +0,0 @@ - -Plot main_mode distribution as a bar Chart — plotModalSplitBarChart • matsim - Skip to contents - - -
-
-
- -
-

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

-
- -
-

Usage

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

Arguments

-
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

- -
-
-

Value

- - -

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

-
-
-

Details

-

Function automatically detects transport_modes from table -and plots pie chart with percentage of distribution. -Using parameters unite.columns, specific columns could be given, to unite them in 1 mode with the name united.name(by default 'united')

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/plotModalSplitPieChart.html b/docs/reference/plotModalSplitPieChart.html deleted file mode 100644 index ad9389f..0000000 --- a/docs/reference/plotModalSplitPieChart.html +++ /dev/null @@ -1,120 +0,0 @@ - -Plot main_mode distribution as a Pie Chart — plotModalSplitPieChart • matsim - Skip to contents - - -
-
-
- -
-

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

-
- -
-

Usage

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

Arguments

-
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

- -
-
-

Value

- - -

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

-
-
-

Details

-

Function automatically detects transport_modes from table -and plots pie chart. -Using parameters unite.columns, specific columns could be given, to unite them in 1 mode with the name united.name(by default 'united')

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/plotStartActCountByDepTime.html b/docs/reference/plotStartActCountByDepTime.html deleted file mode 100644 index 8ef25bb..0000000 --- a/docs/reference/plotStartActCountByDepTime.html +++ /dev/null @@ -1,117 +0,0 @@ - -Scatter plot with departure time x-axis and number start activities on y-axis — plotStartActCountByDepTime • matsim - Skip to contents - - -
-
-
- -
-

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

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

Arguments

-
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

- -
-
-

Value

- - -

Bar Chart plot of distance traveled per mode

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/plotTripCountByDepTime.html b/docs/reference/plotTripCountByDepTime.html deleted file mode 100644 index ba7e24a..0000000 --- a/docs/reference/plotTripCountByDepTime.html +++ /dev/null @@ -1,117 +0,0 @@ - -Line plot with departure time x-axis and number of trips on y-axis — plotTripCountByDepTime • matsim - Skip to contents - - -
-
-
- -
-

Takes Table trips_output (from readTripsTable()), -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')

-
- -
-

Usage

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

Arguments

-
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

- -
-
-

Value

- - -

Line Chart plot of trips count by departure mode per mode

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/plotTripDistanceByMode.html b/docs/reference/plotTripDistanceByMode.html deleted file mode 100644 index 56c5373..0000000 --- a/docs/reference/plotTripDistanceByMode.html +++ /dev/null @@ -1,117 +0,0 @@ - -Bar Chart with distance travelled on x-axis and number of trips on y-axis — plotTripDistanceByMode • matsim - Skip to contents - - -
-
-
- -
-

Takes Table trips_output (from readTripsTable()), -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')

-
- -
-

Usage

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

Arguments

-
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

- -
-
-

Value

- - -

Bar Chart plot of distance traveled per mode

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/plotTripDistancedByType.html b/docs/reference/plotTripDistancedByType.html deleted file mode 100644 index aa0f775..0000000 --- a/docs/reference/plotTripDistancedByType.html +++ /dev/null @@ -1,109 +0,0 @@ - -Bar Chart with tripType on x-axis and travelled distance on y-axis — plotTripDistancedByType • matsim - Skip to contents - - -
-
-
- -
-

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

-
- -
-

Usage

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

Arguments

-
tripsTable
-

tible of trips_output (from readTripsTable())

- - -
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

- - -
dump.output.to
-

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

- -
-
-

Value

- - -

Bar Chart plot of distance traveled by type

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/plotTripTypesPieChart.html b/docs/reference/plotTripTypesPieChart.html deleted file mode 100644 index cf118b7..0000000 --- a/docs/reference/plotTripTypesPieChart.html +++ /dev/null @@ -1,94 +0,0 @@ - -Plots distribution of every type of trips(inside, outside, origin and destinating) in Pie Chart — plotTripTypesPieChart • matsim - Skip to contents - - -
-
-
- -
-

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

-
- -
-

Usage

-
plotTripTypesPieChart(table, shapeTable, crs)
-
- -
-

Arguments

-
table
-

tibble of trips_output (from readTripsTable())

- - -
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

- -
-
-

Value

- - -

plot with percentage of each type of trips

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/plot_arrtime_by_act.html b/docs/reference/plot_arrtime_by_act.html new file mode 100644 index 0000000..83acc08 --- /dev/null +++ b/docs/reference/plot_arrtime_by_act.html @@ -0,0 +1,115 @@ + +Plot Arrival Time by Activity — plot_arrtime_by_act • matsim + Skip to contents + + +
+
+
+ +
+

plot_arrtime_by_act - 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')

+
+ +
+

Usage

+
plot_arrtime_by_act(
+  trips_table,
+  unite_activities = character(0),
+  united_name = "united"
+)
+
+ +
+

Arguments

+
trips_table
+

tibble of trips_output (from read_output_trips)

+ + +
unite_activities
+

vector of character strings, that represent patterns of columns to be united, changes name of all activity types 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 plot

+ +
+
+

Value

+ + +

A plotly object representing the line plot of arrival time by activity.

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/plot_compare_count_by_spatialcat_barchart.html b/docs/reference/plot_compare_count_by_spatialcat_barchart.html new file mode 100644 index 0000000..2dd1f86 --- /dev/null +++ b/docs/reference/plot_compare_count_by_spatialcat_barchart.html @@ -0,0 +1,121 @@ + +Plot Comparison of Count by Spatial Category (Bar Chart) — plot_compare_count_by_spatialcat_barchart • matsim + Skip to contents + + +
+
+
+ +
+

The plot_compare_count_by_spatialcat_barchart +function generates a bar chart to compare the count of trips between two trips_table +tibbles across different spatial categories. +It provides insights into the distribution of trips across spatial categories for each table.

+
+ +
+

Usage

+
plot_compare_count_by_spatialcat_barchart(
+  trips_table1,
+  trips_table2,
+  shape_table,
+  crs
+)
+
+ +
+

Arguments

+
trips_table1
+

tible of trips_output (from read_output_trips)

+ + +
trips_table2
+

tible of trips_output (from read_output_trips)

+ + +
shape_table
+

A spatial shapefile or spatial polygons data frame used to create the spatial categories.

+ + +
crs
+

numeric representation of the EPSG code or proj4string for the corresponding coordinate system of the trip coordinates, +can be found in network file from output directory of MATSim simulation

+ +
+
+

Value

+ + +

A plotly object representing the bar chart of the comparison of count by spatial category.

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/plot_compare_distcat_by_mainmode_barchart.html b/docs/reference/plot_compare_distcat_by_mainmode_barchart.html new file mode 100644 index 0000000..72a5e47 --- /dev/null +++ b/docs/reference/plot_compare_distcat_by_mainmode_barchart.html @@ -0,0 +1,141 @@ + +Bar chart comparing distance traveled on x-axis and number of trips on y-axis for two different runs +Takes two data frames (from read_output_trips), categorizes the traveled distances into pre-defined bins +and plots the difference in number of trips for each bin. (Bins: 1000,2000,5000,10000,20000,50000,100000 (m)) +Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') — plot_compare_distcat_by_mainmode_barchart • matsim + Skip to contents + + +
+
+
+ +
+

Bar chart comparing distance traveled on x-axis and number of trips on y-axis for two different runs +Takes two data frames (from read_output_trips), categorizes the traveled distances into pre-defined bins +and plots the difference in number of trips for each bin. (Bins: 1000,2000,5000,10000,20000,50000,100000 (m)) +Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united')

+
+ +
+

Usage

+
plot_compare_distcat_by_mainmode_barchart(
+  trips_table1,
+  trips_table2,
+  unite_modes = character(0),
+  united_name = "united",
+  dist_column = "dist_cat",
+  distances_array = c(1000, 2000, 5000, 10000, 20000, 50000, 1e+05)
+)
+
+ +
+

Arguments

+
trips_table1
+

tibble of trips_output (from read_output_trips), number of trips of this table will be extracted from number of trips of tripsTable1

+ + +
trips_table2
+

tibble of trips_output (from read_output_trips), from number of trips of this table number of trips of tripsTable1 will be extracted

+ + +
unite_modes
+

vector of character strings, +changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +using the function (process_rename_mainmodes)

+ + +
united_name
+

character string, specifies the name of the united mode

+ + +
dist_column
+

A character string specifying the column name in the trips_table tibble that contains the distance categories.

+ + +
distances_array
+

A numeric vector defining the distance thresholds for creating distance categories.

+ +
+
+

Value

+ + +

Bar Chart plot of count of trips among distance travelled

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/plot_compare_mainmode_barchart.html b/docs/reference/plot_compare_mainmode_barchart.html new file mode 100644 index 0000000..d8e5c77 --- /dev/null +++ b/docs/reference/plot_compare_mainmode_barchart.html @@ -0,0 +1,119 @@ + +Plot bar chart of changes in modal split — plot_compare_mainmode_barchart • matsim + Skip to contents + + +
+
+
+ +
+

Takes two data frames (from read_output_trips), calculates the +changes in mode shares and plots them as a bar chart +Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united')

+
+ +
+

Usage

+
plot_compare_mainmode_barchart(
+  trips_table1,
+  trips_table2,
+  unite_modes = character(0),
+  united_name = "united"
+)
+
+ +
+

Arguments

+
trips_table1
+

tibble of trips_output (from read_output_trips)

+ + +
trips_table2
+

tibble of trips_output (from read_output_trips)

+ + +
unite_modes
+

vector of character strings, +changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +using the function (process_rename_mainmodes)

+ + +
united_name
+

character string, specifies the name of the united mode

+ +
+
+

Value

+ + +

plots bar chart of changes in modal split

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/plot_compare_mainmode_sankey.html b/docs/reference/plot_compare_mainmode_sankey.html new file mode 100644 index 0000000..2827f0b --- /dev/null +++ b/docs/reference/plot_compare_mainmode_sankey.html @@ -0,0 +1,124 @@ + +Plot alluvial/sankey diagram of transport mode changes — plot_compare_mainmode_sankey • matsim + Skip to contents + + +
+
+
+ +
+

Takes two data frames (from read_output_trips) and compares the mode choice for each agent and summarizes the results, showing the modal shift. +Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') +The parameter show.onlyChanges allows the visualization of only the mode shift (excluding the trips that do not change mode). Standard value is FALSE.

+
+ +
+

Usage

+
plot_compare_mainmode_sankey(
+  trips_table1,
+  trips_table2,
+  show_onlychanges = FALSE,
+  unite_modes = character(0),
+  united_name = "united"
+)
+
+ +
+

Arguments

+
trips_table1
+

tibble of trips_output (from read_output_trips())

+ + +
trips_table2
+

tibble of trips_output (from read_output_trips())

+ + +
show_onlychanges
+

boolean, if it is set to TRUE the sankey diagram only shows the mode shift

+ + +
unite_modes
+

vector of character strings, +changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +using the function (process_rename_mainmodes)

+ + +
united_name
+

character string, specifies the name of the united mode

+ +
+
+

Value

+ + +

Alluvial diagram that represents changes in transport mode distribution

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/plot_compare_score_boxplot.html b/docs/reference/plot_compare_score_boxplot.html new file mode 100644 index 0000000..674639e --- /dev/null +++ b/docs/reference/plot_compare_score_boxplot.html @@ -0,0 +1,104 @@ + +Boxplot of Score Differences — plot_compare_score_boxplot • matsim + Skip to contents + + +
+
+
+ +
+

The 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.

+
+ +
+

Usage

+
plot_compare_score_boxplot(personTibble_base, personTibble_policy)
+
+ +
+

Arguments

+
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.

+ +
+
+

Value

+ + +

ggplot boxplot of the distribution of the score differences

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/plot_compare_travelwaittime_by_mainmode.html b/docs/reference/plot_compare_travelwaittime_by_mainmode.html new file mode 100644 index 0000000..c286017 --- /dev/null +++ b/docs/reference/plot_compare_travelwaittime_by_mainmode.html @@ -0,0 +1,124 @@ + +Bar Chart comparing two runs with main_mode on x-axis and average travel/wait time on y-axis — plot_compare_travelwaittime_by_mainmode • matsim + Skip to contents + + +
+
+
+ +
+

Takes two data frames (from read_output_trips), +to plot a comparison bar chart of travel and wait times. +Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united')

+
+ +
+

Usage

+
plot_compare_travelwaittime_by_mainmode(
+  trips_table1,
+  trips_table2,
+  unite_modes = character(0),
+  united_name = "united",
+  time_format = "minute"
+)
+
+ +
+

Arguments

+
trips_table1
+

tibble of trips_output (from read_output_trips)

+ + +
trips_table2
+

tibble of trips_output (from read_output_trips)

+ + +
unite_modes
+

vector of character strings, +changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +using the function (process_rename_mainmodes)

+ + +
united_name
+

character string, specifies the name of the united mode#'

+ + +
time_format
+

character string, defines time format to be used(takes "hour", "minute", "second")

+ +
+
+

Value

+ + +

Bar chart plot comparing average time spent on travel/wait of two runs

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/plot_compare_travelwaittime_by_mainmode_barchart.html b/docs/reference/plot_compare_travelwaittime_by_mainmode_barchart.html new file mode 100644 index 0000000..906bacc --- /dev/null +++ b/docs/reference/plot_compare_travelwaittime_by_mainmode_barchart.html @@ -0,0 +1,124 @@ + +Comparison bar chart with main_mode on x-axis and average travel/wait time on y-axis — plot_compare_travelwaittime_by_mainmode_barchart • matsim + Skip to contents + + +
+
+
+ +
+

Takes the data frame trips_output (from read_output_trips), +to plot a bar chart of the traveling/waiting time +Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united')

+
+ +
+

Usage

+
plot_compare_travelwaittime_by_mainmode_barchart(
+  trips_table1,
+  trips_table2,
+  unite_modes = character(0),
+  united_name = "united",
+  time_format = "minute"
+)
+
+ +
+

Arguments

+
trips_table1
+

tibble of trips_output (from read_output_trips)

+ + +
trips_table2
+

tibble of trips_output (from read_output_trips)

+ + +
unite_modes
+

vector of character strings, +changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +using the function (process_rename_mainmodes)

+ + +
united_name
+

character string, specifies the name of the united mode

+ + +
time_format
+

character string, defines time format to be used(takes "hour", "minute", "second")

+ +
+
+

Value

+ + +

Bar chart plot of average travel/wait time

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/compareTripTypesBarChart.html b/docs/reference/plot_deptime_by_act.html similarity index 50% rename from docs/reference/compareTripTypesBarChart.html rename to docs/reference/plot_deptime_by_act.html index f4ae6fb..55317c3 100644 --- a/docs/reference/compareTripTypesBarChart.html +++ b/docs/reference/plot_deptime_by_act.html @@ -1,9 +1,7 @@ -Creates BarChart of changing trip types(originating,transit etc) between 2 tables -and saves output to dump.output.to — compareTripTypesBarChart • matsimPlot Departure Time by Activity — plot_deptime_by_act • matsim @@ -14,7 +12,7 @@ matsim - 0.1.8 + 0.2.0 + + + + + +
+
+
+ +
+

Takes the data frame trips_output (from read_output_trips), +to plot a bar chart of the average distance traveled for each main mode, +Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united')

+
+ +
+

Usage

+
plot_distance_by_mainmode_barchart(
+  trips_table,
+  unite_modes = character(0),
+  united_name = "united",
+  euclidean = FALSE
+)
+
+ +
+

Arguments

+
trips_table
+

tibble of trips_output (from read_output_trips)

+ + +
unite_modes
+

vector of character strings, +changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +using the function (process_rename_mainmodes)

+ + +
united_name
+

character string, specifies the name of the united mode

+ + +
euclidean
+

Logical value indicating whether to calculate the average as euclidean distance or as travel distance. Default is FALSE, which calculates the average traveled distance.

+ +
+
+

Value

+ + +

Bar Chart plot of distance traveled per mode

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/plotTripsByDistance.html b/docs/reference/plot_distance_by_spatialcat_barchart.html similarity index 62% rename from docs/reference/plotTripsByDistance.html rename to docs/reference/plot_distance_by_spatialcat_barchart.html index 64569fd..b2d12d9 100644 --- a/docs/reference/plotTripsByDistance.html +++ b/docs/reference/plot_distance_by_spatialcat_barchart.html @@ -1,11 +1,9 @@ -Bar Chart with distance travelled on x-axis and number of trips on y-axis — plotTripsByDistance • matsimBar Chart with tripType on x-axis and travelled distance on y-axis — plot_distance_by_spatialcat_barchart • matsim @@ -16,7 +14,7 @@ matsim - 0.1.7 + 0.2.0 + + + + + +
+
+
+ +
+

Takes the data frame trips_output (from read_output_trips) and categorizes the traveled distances into pre-defined bins +to plot a histogram of the traveled distances. (Bins: 1000,2000,5000,10000,20000,50000,100000 (m)) +Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united')

+
+ +
+

Usage

+
plot_distcat_by_mainmode_barchart(
+  trips_table,
+  unite_modes = character(0),
+  united_name = "united",
+  dist_column = "dist_cat",
+  distances_array = c(1000, 2000, 5000, 10000, 20000, 50000, 1e+05)
+)
+
+ +
+

Arguments

+
trips_table
+

tibble of trips_output (from read_output_trips)

+ + +
unite_modes
+

vector of character strings, +changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +using the function (process_rename_mainmodes)

+ + +
united_name
+

character string, specifies the name of the united mode

+ + +
dist_column
+

A character string specifying the column name in the trips_table tibble that contains the distance categories.

+ + +
distances_array
+

A numeric vector defining the distance thresholds for creating distance categories.

+ +
+
+

Value

+ + +

Plotly bar Chart of count of trips among distance travelled

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/plot_mainmode_barchart.html b/docs/reference/plot_mainmode_barchart.html new file mode 100644 index 0000000..0b26499 --- /dev/null +++ b/docs/reference/plot_mainmode_barchart.html @@ -0,0 +1,121 @@ + +Plot the distribution of modes as a bar chart — plot_mainmode_barchart • matsim + Skip to contents + + +
+
+
+ +
+

Takes the data frame trips_output (from read_output_trips) +to plot a bar chart of the modal split using the column main_mode.

+
+ +
+

Usage

+
plot_mainmode_barchart(
+  trips_table,
+  unite_modes = character(0),
+  united_name = "united",
+  percentage = FALSE
+)
+
+ +
+

Arguments

+
trips_table
+

tibble of trips_output (from read_output_trips)

+ + +
unite_modes
+

vector of character strings, +changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +using the function (process_rename_mainmodes)

+ + +
united_name
+

character string, specifies the name of the united mode

+ + +
percentage
+

boolean, by default FALSE, sets if output is given in percentage

+ +
+
+

Value

+ + +

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

+
+
+

Details

+

The modal shares are given in percentages.

+

Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united')

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/plot_mainmode_piechart.html b/docs/reference/plot_mainmode_piechart.html new file mode 100644 index 0000000..a2d5357 --- /dev/null +++ b/docs/reference/plot_mainmode_piechart.html @@ -0,0 +1,116 @@ + +Plot the distribution of modes as a pie chart — plot_mainmode_piechart • matsim + Skip to contents + + +
+
+
+ +
+

Uses the dataframe trips_output (from read_output_trips), +to plot a pie chart of the modal split using the column main_mode

+
+ +
+

Usage

+
plot_mainmode_piechart(
+  trips_table,
+  unite_modes = character(0),
+  united_name = "united"
+)
+
+ +
+

Arguments

+
trips_table
+

tibble of trips_output (from read_output_trips)

+ + +
unite_modes
+

vector of character strings, +changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +using the function (process_rename_mainmodes)

+ + +
united_name
+

character string, specifies the name of the united mode

+ +
+
+

Value

+ + +

pie chart plot of transport mode distribution, values given in percent

+
+
+

Details

+

The function automatically detects the modes plots a pie chart. +Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united')

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/plotEndActCountByArrTime.html b/docs/reference/plot_map_trips.html similarity index 59% rename from docs/reference/plotEndActCountByArrTime.html rename to docs/reference/plot_map_trips.html index 31b573d..76f0271 100644 --- a/docs/reference/plotEndActCountByArrTime.html +++ b/docs/reference/plot_map_trips.html @@ -1,11 +1,5 @@ -Scatter plot with arrival time x-axis and number end activities on y-axis — plotEndActCountByArrTime • matsimPlots start and end coordinates of the given trips table on an osm map — plot_map_trips • matsim @@ -16,7 +10,7 @@ matsim - 0.1.7 + 0.2.0 + + + + + +
+
+
+ +
+

Plots every type of trips(inside, outside, origin and destinating) on map

+
+ +
+

Usage

+
plot_map_trips_by_spatialcat(trips_table, shape_table, crs, optimized = FALSE)
+
+ +
+

Arguments

+
trips_table
+

tibble of trips_output (from read_output_trips)

+ + +
shape_table
+

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

+ + +
crs
+

numeric representation of the EPSG code or proj4string for the corresponding coordinate system +of the trip coordinates, can be found in network file from output directory of MATSim simulation

+ + +
optimized
+

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

+ + +
table
+

tibble of output_trips (from read_output_trips())

+ + +
shape_Table
+

sf object(data frame with geometries), can be created using st_read(), is used to categorize the trips.

+ +
+
+

Value

+ + +

plot that contains every trip with defined trip type

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/plot_spatialtype_by_shape_piechart.html b/docs/reference/plot_spatialtype_by_shape_piechart.html new file mode 100644 index 0000000..01b2fd8 --- /dev/null +++ b/docs/reference/plot_spatialtype_by_shape_piechart.html @@ -0,0 +1,103 @@ + +Plots distribution of every type of trip(inside, outside, origin and destinating) as a pie chart — plot_spatialtype_by_shape_piechart • matsim + Skip to contents + + +
+
+
+ +
+

Plots distribution of every type of trip(inside, outside, origin and destinating) as a pie chart

+
+ +
+

Usage

+
plot_spatialtype_by_shape_piechart(trips_table, shape_table, crs)
+
+ +
+

Arguments

+
trips_table
+

tibble of trips_output (from read_output_trips)

+ + +
crs
+

numeric representation of the EPSG code or proj4string for the corresponding coordinate system of the trip coordinates, +can be found in network file from output directory of MATSim simulation

+ + +
shape_Table
+

sf object(data frame with geometries), can be created using st_read(), is used to categorize the trips.

+ +
+
+

Value

+ + +

Pie chart showing the percentage of each type of trip

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/plot_travelwaittime_mean_barchart.html b/docs/reference/plot_travelwaittime_mean_barchart.html new file mode 100644 index 0000000..485c6b7 --- /dev/null +++ b/docs/reference/plot_travelwaittime_mean_barchart.html @@ -0,0 +1,120 @@ + +Plot travel and wait time for each mode as a bar chart — plot_travelwaittime_mean_barchart • matsim + Skip to contents + + +
+
+
+ +
+

Takes the data frame trips_output (from read_output_trips), +to plot a bar chart of travel and wait times. +Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united')

+
+ +
+

Usage

+
plot_travelwaittime_mean_barchart(
+  trips_table,
+  unite_modes = character(0),
+  united_name = "united",
+  time_format = "minute"
+)
+
+ +
+

Arguments

+
trips_table
+

tibble of trips_output (from read_output_trips)

+ + +
unite_modes
+

vector of character strings, +changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +using the function (process_rename_mainmodes)

+ + +
united_name
+

character string, specifies the name of the united mode

+ + +
time_format
+

A character string indicating the desired time format for the output. +The options are "minute", "hour", or "second". The default is "minute".

+ +
+
+

Value

+ + +

Bar Chart plot of average time spent on travel/wait

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/plot_trips_count_by_deptime_and_mainmode_linechart.html b/docs/reference/plot_trips_count_by_deptime_and_mainmode_linechart.html new file mode 100644 index 0000000..0e5b713 --- /dev/null +++ b/docs/reference/plot_trips_count_by_deptime_and_mainmode_linechart.html @@ -0,0 +1,114 @@ + +Line plot with departure time on x-axis and number of trips on y-axis — plot_trips_count_by_deptime_and_mainmode_linechart • matsim + Skip to contents + + +
+
+
+ +
+

Takes data frame trips_output (from read_output_trips), +to create a line plot of the number of trips for a specific departure time by main_mode +Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united')

+
+ +
+

Usage

+
plot_trips_count_by_deptime_and_mainmode_linechart(
+  trips_table,
+  unite_modes = character(0),
+  united_name = "united"
+)
+
+ +
+

Arguments

+
trips_table
+

tibble of trips_output (from read_output_trips)

+ + +
unite_modes
+

vector of character strings, +changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +using the function (process_rename_mainmodes)

+ + +
united_name
+

character string, specifies the name of the united mode

+ +
+
+

Value

+ + +

Line plot of trips count by departure time per mode

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/prepareComparisonSimwrapperDashboardFromTable.html b/docs/reference/prepareComparisonSimwrapperDashboardFromTable.html index 2dd81ec..d951ed2 100644 --- a/docs/reference/prepareComparisonSimwrapperDashboardFromTable.html +++ b/docs/reference/prepareComparisonSimwrapperDashboardFromTable.html @@ -1,5 +1,5 @@ -Creates comparison dashboard for the 2 given tables or folder with data — prepareComparisonSimwrapperDashboardFromTable • matsimCreates comparison dashboard for the two given tables or folders with data — prepareComparisonSimwrapperDashboardFromTable • matsim @@ -10,7 +10,7 @@ matsim - 0.1.8 + 0.2.0 + + + + + +
+
+
+ +
+

Categorizes each trip into a distance bin based on traveled distance. +E.g. distance traveled is 1500, distances array is (1000,2000), then the category is "1000-2000".

+
+ +
+

Usage

+
process_append_distcat(
+  trips_table,
+  distances_array = c(1000, 2000, 5000, 10000, 20000, 50000, 1e+05)
+)
+
+ +
+

Arguments

+
trips_table
+

tibble of output_trips (from read_output_trips)

+ + +
distances_array
+

numeric vector, represents segments for distance categories ordered (in meters), +standard value: c(1000,2000,5000,10000,20000,50000,100000)

+ +
+
+

Value

+ + +

trips table with added the added column dist_cat

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/process_append_spatialcat.html b/docs/reference/process_append_spatialcat.html new file mode 100644 index 0000000..88c746d --- /dev/null +++ b/docs/reference/process_append_spatialcat.html @@ -0,0 +1,119 @@ + +Appends an additional column with the trip type to output_trips — process_append_spatialcat • matsim + Skip to contents + + +
+
+
+ +
+

Using a shape_file of the project area an additional column is created, categorizing all trips into the following categories. +inside: trips that start and end inside the given shape +originating: trips that start inside the shape and end outside of the shape +destinating: trips that end inside the shape and start outside of the shape +outside: trips that start and end outside of the shape

+
+ +
+

Usage

+
process_append_spatialcat(trips_table, shape_table, crs)
+
+ +
+

Arguments

+
trips_table
+

tibble of output_trips (from read_output_trips())

+ + +
crs
+

numeric representation of the EPSG code or proj4string for the corresponding coordinate system +of the trip coordinates, can be found in network file from output directory of MATSim simulation

+ + +
shape_Table
+

sf object(data frame with geometries), can be created using st_read(), is used to categorize the trips.

+ +
+
+

Value

+ + +

tibble, with additional column containing the trip type

+
+
+

Details

+

Please be aware that this process_filter_by_shape currently only works, when one geometry is loaded.)

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/process_convert_table_to_sf.html b/docs/reference/process_convert_table_to_sf.html new file mode 100644 index 0000000..0b044a4 --- /dev/null +++ b/docs/reference/process_convert_table_to_sf.html @@ -0,0 +1,117 @@ + +Transforms the data frame trips_output (from read_output_trips) from tibble to sf (table with geometry features) — process_convert_table_to_sf • matsim + Skip to contents + + +
+
+
+ +
+

Transforms the data frame trips_output (from read_output_trips) into an sf object using start_x, end_x, start_y, end_y as geometry features.
+If geometry.type = st_multipoint() or geometry.type = st_linestring() it adds one geometry column (wkt format),
+if geometry.type = st_point() it adds the geometry columns start_wkt and end_wkt.
+Added column/columns are projected to given CRS (coordinate reference system).
+The columns start_x, end_x, start_y, end_y are deleted from the resulting data frame.

+
+ +
+

Usage

+
process_convert_table_to_sf(table, crs, geometry.type = st_multipoint())
+
+ +
+

Arguments

+
table
+

tibble trips_output (from read_output_trips)

+ + +
crs
+

numeric, coordinate system in the form of the EPSG code or proj4string, can be found in the MATSim network file

+ + +
geometry.type
+

type of sf transformation, default is st_multipoint(), geometry.type can be:
+!!!st_point()- resulting table contains two geometry columns: start_wkt and end_wkt, representing start and end points as POINTS!!! or
+!!!st_multipoint()- resulting table contains one geometry column, representing start and end points as MULTIPOINT!!! or
+!!!st_linestring() - resulting table contains one geometry column, representing the line between start and end points as LINESTRING!!!

+ +
+
+

Value

+ + +

sf object (data frame with geometries depending on geometry.type)

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/process_convert_time.html b/docs/reference/process_convert_time.html new file mode 100644 index 0000000..2ae4234 --- /dev/null +++ b/docs/reference/process_convert_time.html @@ -0,0 +1,112 @@ + +Converts time column specified in time_column to numeric representation of minutes, hours or seconds — process_convert_time • matsim + Skip to contents + + +
+
+
+ +
+

Default output_trips table time columns(dep_time, trav_time, wait_time) are in 'hms' format. +To convert this type to numeric, specify time_column to be converted, +and the unit time_format. Acceptable units are "hour", "minute" and "second".

+
+ +
+

Usage

+
process_convert_time(
+  trips_table,
+  time_format = "hour",
+  time_column = "dep_time"
+)
+
+ +
+

Arguments

+
trips_table
+

tibble of output_trips (from read_output_trips)

+ + +
time_format
+

char, defines time unit to be used ("hour", "minute", "second")

+ + +
time_column
+

char, name of the column from table to be converted (dep_time, trav_time, wait_time)

+ +
+
+

Value

+ + +

tibble, containing column with specified time_format

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/process_filter_by_shape.html b/docs/reference/process_filter_by_shape.html new file mode 100644 index 0000000..b73fa19 --- /dev/null +++ b/docs/reference/process_filter_by_shape.html @@ -0,0 +1,125 @@ + +Filters trips_table(from ,read_output_trips) depending by location using a shapefile — process_filter_by_shape • matsim + Skip to contents + + +
+
+
+ +
+

Uses output_trips and an sf object (can be created using the function st_read()), +transforms both objects to match a mutual coordinate system (crs) +and filters the trips from output_trips depending on their spatial type:
+if spatial_type="inside" returns a table that contains trips inside given shape
+if spatial_type="originating" returns a table that contains trips which start inside the shape and end outside of the shape
+if spatial_type="destinating" returns a table that contains trips which end inside shape and start outside of the shape
+if spatial_type="outside" returns a table that contains trips which start and end outside of the given shape

+
+ +
+

Usage

+
process_filter_by_shape(trips_table, shape_table, crs, spatial_type = "inside")
+
+ +
+

Arguments

+
trips_table
+

tibble of trips_output (from read_output_trips)

+ + +
crs
+

numeric representation of the EPSG code or proj4string for the corresponding coordinate system +of the trip coordinates, can be found in network file from output directory of MATSim simulation

+ + +
spatial_type
+

bool, defines trips to conclude (see description)

+ + +
shape_Table
+

sf object(data frame with geometries), can be created using st_read()

+ +
+
+

Value

+ + +

tibble, with filtered trips depending on shapeTable and spatial types (see description)

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/plotDistanceTraveledByType.html b/docs/reference/process_get_crs_from_config.html similarity index 66% rename from docs/reference/plotDistanceTraveledByType.html rename to docs/reference/process_get_crs_from_config.html index 41836ec..d2adcc4 100644 --- a/docs/reference/plotDistanceTraveledByType.html +++ b/docs/reference/process_get_crs_from_config.html @@ -1,9 +1,5 @@ -Bar Chart with tripType on x-axis and travelled distance on y-axis — plotDistanceTraveledByType • matsimReads the coordinate reference system from a MATSim output directory (output_config.xml) — process_get_crs_from_config • matsim @@ -14,7 +10,7 @@ matsim - 0.1.7 + 0.2.0 + + + + + +
+
+
+ +
+

The process_get_mainmode_distribution function calculates the distribution of main modes in a given trips_table.
+It provides insights into the frequency or percentage of each main mode within the dataset.

+
+ +
+

Usage

+
process_get_mainmode_distribution(trips_table, percentage = FALSE)
+
+ +
+

Arguments

+
trips_table
+

tible of output_trips (from read_output_trips)

+ + +
percentage
+

boolean, by default FALSE, sets if output should be given in percentage

+ +
+
+

Value

+ + +

tibble that provides the distribution of main modes in the input trips_table.

+
+
+

Details

+

By default, the function counts the occurrences of each main mode in the trips_table tibble and returns the counts for each unique main mode.
+Alternatively, when the percentage parameter is set to TRUE, the function normalizes the counts to represent the percentage distribution of each main mode within the dataset.

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/process_get_od_matrix.html b/docs/reference/process_get_od_matrix.html new file mode 100644 index 0000000..e9c030a --- /dev/null +++ b/docs/reference/process_get_od_matrix.html @@ -0,0 +1,132 @@ + +Creates an origin/destination matrix either in conventional form (row names = origin, column names = destination) +or for simwrapper (origin and destination as columns) — process_get_od_matrix • matsim + Skip to contents + + +
+
+
+ +
+

Creates an origin/destination matrix either in conventional form (row names = origin, column names = destination) +or for simwrapper (origin and destination as columns)

+
+ +
+

Usage

+
process_get_od_matrix(
+  trips_table,
+  shape_path,
+  crs,
+  dump.output.to = matsimDumpOutputDirectory,
+  simwrapper = FALSE,
+  colnames = "numeric",
+  outer = FALSE
+)
+
+ +
+

Arguments

+
trips_table
+

tibble of trips_output (from read_output_trips)

+ + +
shape_path
+

string, full path to the shapefile (.shp) (shape files are made up of several files with the same name and the folder also needs to include a .dbf file)

+ + +
crs
+

numeric, coordinate system in the form of the EPSG code or proj4string, can be found in the MATSim network file

+ + +
dump.output.to
+

string, path to a folder to save the .csv file

+ + +
simwrapper
+

boolean, creates output in the format used for simwrapper if the path for the shapefile is specified

+ + +
colnames
+

string, column names can be specified (i.e. to fit the shape file), if not they are numbered

+ + +
outer
+

boolean, determines if flows outside of the shapefile are used, standard value is FALSE

+ +
+
+

Value

+ + +

tibble of origin/destination matrix

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/process_get_travdistance_distribution.html b/docs/reference/process_get_travdistance_distribution.html new file mode 100644 index 0000000..900f7fd --- /dev/null +++ b/docs/reference/process_get_travdistance_distribution.html @@ -0,0 +1,98 @@ + +Get Travel Distance Distribution by Main Mode — process_get_travdistance_distribution • matsim + Skip to contents + + +
+
+
+ +
+

The process_get_travdistance_distribution function calculates the distribution of travel distances based on main modes in a given trips_table tibble. It provides insights into the average distance traveled for each main mode.

+
+ +
+

Usage

+
process_get_travdistance_distribution(trips_table, euclidean = FALSE)
+
+ +
+

Arguments

+
trips_table
+

A tibble of output_trips (from read_output_trips)

+ + +
euclidean
+

Logical value indicating whether to calculate the average as euclidean distance or as travel distance. Default is FALSE, which calculates the average traveled distance.

+ +
+
+

Value

+ + +

A tibble containing the main_mode column representing unique main modes and the avg_dist column representing the average travel distance for each main mode.

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/process_get_travelwaittime_by_mainmode.html b/docs/reference/process_get_travelwaittime_by_mainmode.html new file mode 100644 index 0000000..154209e --- /dev/null +++ b/docs/reference/process_get_travelwaittime_by_mainmode.html @@ -0,0 +1,98 @@ + +Get Travel and Wait Time by Main Mode — process_get_travelwaittime_by_mainmode • matsim + Skip to contents + + +
+
+
+ +
+

The process_get_travelwaittime_by_mainmode function calculates the average travel time and average wait time for each main mode in a given trips_table tibble.

+
+ +
+

Usage

+
process_get_travelwaittime_by_mainmode(trips_table, time_format = "minute")
+
+ +
+

Arguments

+
trips_table
+

A tibble of output_trips (from read_output_trips)

+ + +
time_format
+

A character string indicating the desired time format for the output. The options are "minute", "hour", or "second". The default is "minute".

+ +
+
+

Value

+ + +

A tibble containing the main_mode column representing unique main modes, trav_time_avg column representing the average travel time for each main mode, and wait_time_avg column representing the average wait time for each main mode.

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/process_rename_category.html b/docs/reference/process_rename_category.html new file mode 100644 index 0000000..a23df19 --- /dev/null +++ b/docs/reference/process_rename_category.html @@ -0,0 +1,123 @@ + +Replace Matching Categories of any column with United Name in Tibble — process_rename_category • matsim + Skip to contents + + +
+
+
+ +
+

The process_rename_category function takes a tibble, trips_table, +as input and replaces all occurrences of categories +that match a given template with another name provided in united_name. +The function provides the flexibility to specify multiple category templates +to be united into a single name.

+
+ +
+

Usage

+
process_rename_category(
+  trips_table,
+  unite_template = character(0),
+  united_name = "united",
+  column = "main_mode"
+)
+
+ +
+

Arguments

+
trips_table
+

tible of output_trips (from read_output_trips)

+ + +
unite_template
+

vector of character string, representing pattern to match categories

+ + +
united_name
+

character string, to represent new category for all occurrences matched unite_modes

+ + +
column
+

tibble column name, which will be used in occurrences renaming

+ +
+
+

Value

+ + +

modified trips table tibble

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/process_rename_mainmodes.html b/docs/reference/process_rename_mainmodes.html new file mode 100644 index 0000000..24306a7 --- /dev/null +++ b/docs/reference/process_rename_mainmodes.html @@ -0,0 +1,119 @@ + +Replace Matching Categories of main_mode with United Name in Tibble — process_rename_mainmodes • matsim + Skip to contents + + +
+
+
+ +
+

The process_rename_mainmodes function takes a tibble, trips_table, +as input and replaces all occurrences in column main_mode of categories +that match a given template with another name provided in united_name. +The function provides the flexibility to specify multiple category templates +to be united into a single name.

+
+ +
+

Usage

+
process_rename_mainmodes(
+  trips_table,
+  unite_modes = character(0),
+  united_name = "united"
+)
+
+ +
+

Arguments

+
trips_table
+

tibble of output_trips (from read_output_trips)

+ + +
unite_modes
+

vector of character strings, +changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt)

+ + +
united_name
+

character string, specifies the name of the united mode

+ +
+
+

Value

+ + +

tibble with new main_mode representation

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/readCounts.html b/docs/reference/readCounts.html index a299ff8..4c46055 100644 --- a/docs/reference/readCounts.html +++ b/docs/reference/readCounts.html @@ -1,5 +1,5 @@ -Load a MATSim Counts file into memory — readCounts • matsimLoad a MATSim Counts file into memory — readCounts • matsim @@ -10,7 +10,7 @@ matsim - 0.1.8 + 0.2.0 - - - - - -
-
-
- -
-

Loads a MATSim CSV output_trips from file or archive, -creating a tibble with columns as in csv file

-
- -
-

Usage

-
readTripsTable(input_path = ".")
-
- -
-

Arguments

-
input_path
-

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

- -
-
-

Value

- - -

tibble of trips_output

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/reference/read_config.html b/docs/reference/read_config.html new file mode 100644 index 0000000..6c272d7 --- /dev/null +++ b/docs/reference/read_config.html @@ -0,0 +1,101 @@ + +Load MATSIM config file into Memory — read_config • matsim + Skip to contents + + +
+
+
+ +
+

Loads a MATSim xml config from file or archive, +creating a list with parameters as in xml file

+
+ +
+

Usage

+
read_config(input_path = ".", n_max = Inf)
+
+ +
+

Arguments

+
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

+ +
+
+

Value

+ + +

tibble of trips_output

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/loadNetwork.html b/docs/reference/read_network.html similarity index 57% rename from docs/reference/loadNetwork.html rename to docs/reference/read_network.html index 0658a16..b780594 100644 --- a/docs/reference/loadNetwork.html +++ b/docs/reference/read_network.html @@ -1,7 +1,7 @@ Load MATSim network into memory — loadNetwork • matsimLoad MATSim network into memory — read_network • matsimLoad MATSim output_persons table into memory — read_output_persons • matsim + Skip to contents + + +
+
+
+ +
+

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

+
+ +
+

Usage

+
read_output_persons(input_path = ".", n_max = Inf)
+
+ +
+

Arguments

+
input_path
+

is a character string, path to the local MATSim output directory, to the persons csv directly, or a http link to the file.

+ + +
n_max
+

integer, maximum number of lines to read within output_persons

+ +
+
+

Value

+ + +

tibble of output_persons

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/read_output_trips.html b/docs/reference/read_output_trips.html new file mode 100644 index 0000000..22ba9ea --- /dev/null +++ b/docs/reference/read_output_trips.html @@ -0,0 +1,98 @@ + +Load MATSim output_trips table into memory — read_output_trips • matsim + Skip to contents + + +
+
+
+ +
+

Loads MATSim output_trips.csv from file or archive creating a tibble

+
+ +
+

Usage

+
read_output_trips(input_path = ".", n_max = Inf)
+
+ +
+

Arguments

+
input_path
+

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

+ + +
n_max
+

optional, integer, maximum number of lines to read, standard value is Inf

+ +
+
+

Value

+ + +

tibble of output_trips

+
+ +
+ + +
+ + + +
+ + + + + + + diff --git a/docs/reference/symlog_trans.html b/docs/reference/symlog_trans.html index 1cc21a0..b8d6d2d 100644 --- a/docs/reference/symlog_trans.html +++ b/docs/reference/symlog_trans.html @@ -2,7 +2,7 @@ A function to create symlog scaling for a plot — symlog_trans • matsimA function to create symlog scaling for a plot — symlog_trans • matsimTransforms trips_table tibble (from readTripsTable) from tibble to sf (table with attribute features and geometry feature) — transformToSf • matsim - Skip to contents - - -
-
-
- -
-

Takes trips_table (from readTripsTable) 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

-
- -
-

Usage

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

Arguments

-
table
-

tibble of trips_output (from readTripsTable())

- - -
crs
-

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

- - -
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

- - -

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

-
-
-

Details

-

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

-
- -
- - -
- - - -
- - - - - - - diff --git a/docs/search.json b/docs/search.json index 9f35cda..de2fe14 100644 --- a/docs/search.json +++ b/docs/search.json @@ -1 +1 @@ -[{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"GNU General Public License","title":"GNU General Public License","text":"Version 3, 29 June 2007Copyright © 2007 Free Software Foundation, Inc.  Everyone permitted copy distribute verbatim copies license document, changing allowed.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"preamble","dir":"","previous_headings":"","what":"Preamble","title":"GNU General Public License","text":"GNU General Public License free, copyleft license software kinds works. licenses software practical works designed take away freedom share change works. contrast, GNU General Public License intended guarantee freedom share change versions program–make sure remains free software users. , Free Software Foundation, use GNU General Public License software; applies also work released way authors. can apply programs, . speak free software, referring freedom, price. General Public Licenses designed make sure freedom distribute copies free software (charge wish), receive source code can get want , can change software use pieces new free programs, know can things. protect rights, need prevent others denying rights asking surrender rights. Therefore, certain responsibilities distribute copies software, modify : responsibilities respect freedom others. example, distribute copies program, whether gratis fee, must pass recipients freedoms received. must make sure , , receive can get source code. must show terms know rights. Developers use GNU GPL protect rights two steps: (1) assert copyright software, (2) offer License giving legal permission copy, distribute /modify . developers’ authors’ protection, GPL clearly explains warranty free software. users’ authors’ sake, GPL requires modified versions marked changed, problems attributed erroneously authors previous versions. devices designed deny users access install run modified versions software inside , although manufacturer can . fundamentally incompatible aim protecting users’ freedom change software. systematic pattern abuse occurs area products individuals use, precisely unacceptable. Therefore, designed version GPL prohibit practice products. problems arise substantially domains, stand ready extend provision domains future versions GPL, needed protect freedom users. Finally, every program threatened constantly software patents. States allow patents restrict development use software general-purpose computers, , wish avoid special danger patents applied free program make effectively proprietary. prevent , GPL assures patents used render program non-free. precise terms conditions copying, distribution modification follow.","code":""},{"path":[]},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_0-definitions","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"0. Definitions","title":"GNU General Public License","text":"“License” refers version 3 GNU General Public License. “Copyright” also means copyright-like laws apply kinds works, semiconductor masks. “Program” refers copyrightable work licensed License. licensee addressed “”. “Licensees” “recipients” may individuals organizations. “modify” work means copy adapt part work fashion requiring copyright permission, making exact copy. resulting work called “modified version” earlier work work “based ” earlier work. “covered work” means either unmodified Program work based Program. “propagate” work means anything , without permission, make directly secondarily liable infringement applicable copyright law, except executing computer modifying private copy. Propagation includes copying, distribution (without modification), making available public, countries activities well. “convey” work means kind propagation enables parties make receive copies. Mere interaction user computer network, transfer copy, conveying. interactive user interface displays “Appropriate Legal Notices” extent includes convenient prominently visible feature (1) displays appropriate copyright notice, (2) tells user warranty work (except extent warranties provided), licensees may convey work License, view copy License. interface presents list user commands options, menu, prominent item list meets criterion.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_1-source-code","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"1. Source Code","title":"GNU General Public License","text":"“source code” work means preferred form work making modifications . “Object code” means non-source form work. “Standard Interface” means interface either official standard defined recognized standards body, , case interfaces specified particular programming language, one widely used among developers working language. “System Libraries” executable work include anything, work whole, () included normal form packaging Major Component, part Major Component, (b) serves enable use work Major Component, implement Standard Interface implementation available public source code form. “Major Component”, context, means major essential component (kernel, window system, ) specific operating system () executable work runs, compiler used produce work, object code interpreter used run . “Corresponding Source” work object code form means source code needed generate, install, (executable work) run object code modify work, including scripts control activities. However, include work’s System Libraries, general-purpose tools generally available free programs used unmodified performing activities part work. example, Corresponding Source includes interface definition files associated source files work, source code shared libraries dynamically linked subprograms work specifically designed require, intimate data communication control flow subprograms parts work. Corresponding Source need include anything users can regenerate automatically parts Corresponding Source. Corresponding Source work source code form work.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_2-basic-permissions","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"2. Basic Permissions","title":"GNU General Public License","text":"rights granted License granted term copyright Program, irrevocable provided stated conditions met. License explicitly affirms unlimited permission run unmodified Program. output running covered work covered License output, given content, constitutes covered work. License acknowledges rights fair use equivalent, provided copyright law. may make, run propagate covered works convey, without conditions long license otherwise remains force. may convey covered works others sole purpose make modifications exclusively , provide facilities running works, provided comply terms License conveying material control copyright. thus making running covered works must exclusively behalf, direction control, terms prohibit making copies copyrighted material outside relationship . Conveying circumstances permitted solely conditions stated . Sublicensing allowed; section 10 makes unnecessary.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_3-protecting-users-legal-rights-from-anti-circumvention-law","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"3. Protecting Users’ Legal Rights From Anti-Circumvention Law","title":"GNU General Public License","text":"covered work shall deemed part effective technological measure applicable law fulfilling obligations article 11 WIPO copyright treaty adopted 20 December 1996, similar laws prohibiting restricting circumvention measures. convey covered work, waive legal power forbid circumvention technological measures extent circumvention effected exercising rights License respect covered work, disclaim intention limit operation modification work means enforcing, work’s users, third parties’ legal rights forbid circumvention technological measures.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_4-conveying-verbatim-copies","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"4. Conveying Verbatim Copies","title":"GNU General Public License","text":"may convey verbatim copies Program’s source code receive , medium, provided conspicuously appropriately publish copy appropriate copyright notice; keep intact notices stating License non-permissive terms added accord section 7 apply code; keep intact notices absence warranty; give recipients copy License along Program. may charge price price copy convey, may offer support warranty protection fee.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_5-conveying-modified-source-versions","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"5. Conveying Modified Source Versions","title":"GNU General Public License","text":"may convey work based Program, modifications produce Program, form source code terms section 4, provided also meet conditions: ) work must carry prominent notices stating modified , giving relevant date. b) work must carry prominent notices stating released License conditions added section 7. requirement modifies requirement section 4 “keep intact notices”. c) must license entire work, whole, License anyone comes possession copy. License therefore apply, along applicable section 7 additional terms, whole work, parts, regardless packaged. License gives permission license work way, invalidate permission separately received . d) work interactive user interfaces, must display Appropriate Legal Notices; however, Program interactive interfaces display Appropriate Legal Notices, work need make . compilation covered work separate independent works, nature extensions covered work, combined form larger program, volume storage distribution medium, called “aggregate” compilation resulting copyright used limit access legal rights compilation’s users beyond individual works permit. Inclusion covered work aggregate cause License apply parts aggregate.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_6-conveying-non-source-forms","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"6. Conveying Non-Source Forms","title":"GNU General Public License","text":"may convey covered work object code form terms sections 4 5, provided also convey machine-readable Corresponding Source terms License, one ways: ) Convey object code , embodied , physical product (including physical distribution medium), accompanied Corresponding Source fixed durable physical medium customarily used software interchange. b) Convey object code , embodied , physical product (including physical distribution medium), accompanied written offer, valid least three years valid long offer spare parts customer support product model, give anyone possesses object code either (1) copy Corresponding Source software product covered License, durable physical medium customarily used software interchange, price reasonable cost physically performing conveying source, (2) access copy Corresponding Source network server charge. c) Convey individual copies object code copy written offer provide Corresponding Source. alternative allowed occasionally noncommercially, received object code offer, accord subsection 6b. d) Convey object code offering access designated place (gratis charge), offer equivalent access Corresponding Source way place charge. need require recipients copy Corresponding Source along object code. place copy object code network server, Corresponding Source may different server (operated third party) supports equivalent copying facilities, provided maintain clear directions next object code saying find Corresponding Source. Regardless server hosts Corresponding Source, remain obligated ensure available long needed satisfy requirements. e) Convey object code using peer--peer transmission, provided inform peers object code Corresponding Source work offered general public charge subsection 6d. separable portion object code, whose source code excluded Corresponding Source System Library, need included conveying object code work. “User Product” either (1) “consumer product”, means tangible personal property normally used personal, family, household purposes, (2) anything designed sold incorporation dwelling. determining whether product consumer product, doubtful cases shall resolved favor coverage. particular product received particular user, “normally used” refers typical common use class product, regardless status particular user way particular user actually uses, expects expected use, product. product consumer product regardless whether product substantial commercial, industrial non-consumer uses, unless uses represent significant mode use product. “Installation Information” User Product means methods, procedures, authorization keys, information required install execute modified versions covered work User Product modified version Corresponding Source. information must suffice ensure continued functioning modified object code case prevented interfered solely modification made. convey object code work section , , specifically use , User Product, conveying occurs part transaction right possession use User Product transferred recipient perpetuity fixed term (regardless transaction characterized), Corresponding Source conveyed section must accompanied Installation Information. requirement apply neither third party retains ability install modified object code User Product (example, work installed ROM). requirement provide Installation Information include requirement continue provide support service, warranty, updates work modified installed recipient, User Product modified installed. Access network may denied modification materially adversely affects operation network violates rules protocols communication across network. Corresponding Source conveyed, Installation Information provided, accord section must format publicly documented (implementation available public source code form), must require special password key unpacking, reading copying.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_7-additional-terms","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"7. Additional Terms","title":"GNU General Public License","text":"“Additional permissions” terms supplement terms License making exceptions one conditions. Additional permissions applicable entire Program shall treated though included License, extent valid applicable law. additional permissions apply part Program, part may used separately permissions, entire Program remains governed License without regard additional permissions. convey copy covered work, may option remove additional permissions copy, part . (Additional permissions may written require removal certain cases modify work.) may place additional permissions material, added covered work, can give appropriate copyright permission. Notwithstanding provision License, material add covered work, may (authorized copyright holders material) supplement terms License terms: ) Disclaiming warranty limiting liability differently terms sections 15 16 License; b) Requiring preservation specified reasonable legal notices author attributions material Appropriate Legal Notices displayed works containing ; c) Prohibiting misrepresentation origin material, requiring modified versions material marked reasonable ways different original version; d) Limiting use publicity purposes names licensors authors material; e) Declining grant rights trademark law use trade names, trademarks, service marks; f) Requiring indemnification licensors authors material anyone conveys material (modified versions ) contractual assumptions liability recipient, liability contractual assumptions directly impose licensors authors. non-permissive additional terms considered “restrictions” within meaning section 10. Program received , part , contains notice stating governed License along term restriction, may remove term. license document contains restriction permits relicensing conveying License, may add covered work material governed terms license document, provided restriction survive relicensing conveying. add terms covered work accord section, must place, relevant source files, statement additional terms apply files, notice indicating find applicable terms. Additional terms, permissive non-permissive, may stated form separately written license, stated exceptions; requirements apply either way.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_8-termination","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"8. Termination","title":"GNU General Public License","text":"may propagate modify covered work except expressly provided License. attempt otherwise propagate modify void, automatically terminate rights License (including patent licenses granted third paragraph section 11). However, cease violation License, license particular copyright holder reinstated () provisionally, unless copyright holder explicitly finally terminates license, (b) permanently, copyright holder fails notify violation reasonable means prior 60 days cessation. Moreover, license particular copyright holder reinstated permanently copyright holder notifies violation reasonable means, first time received notice violation License (work) copyright holder, cure violation prior 30 days receipt notice. Termination rights section terminate licenses parties received copies rights License. rights terminated permanently reinstated, qualify receive new licenses material section 10.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_9-acceptance-not-required-for-having-copies","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"9. Acceptance Not Required for Having Copies","title":"GNU General Public License","text":"required accept License order receive run copy Program. Ancillary propagation covered work occurring solely consequence using peer--peer transmission receive copy likewise require acceptance. However, nothing License grants permission propagate modify covered work. actions infringe copyright accept License. Therefore, modifying propagating covered work, indicate acceptance License .","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_10-automatic-licensing-of-downstream-recipients","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"10. Automatic Licensing of Downstream Recipients","title":"GNU General Public License","text":"time convey covered work, recipient automatically receives license original licensors, run, modify propagate work, subject License. responsible enforcing compliance third parties License. “entity transaction” transaction transferring control organization, substantially assets one, subdividing organization, merging organizations. propagation covered work results entity transaction, party transaction receives copy work also receives whatever licenses work party’s predecessor interest give previous paragraph, plus right possession Corresponding Source work predecessor interest, predecessor can get reasonable efforts. may impose restrictions exercise rights granted affirmed License. example, may impose license fee, royalty, charge exercise rights granted License, may initiate litigation (including cross-claim counterclaim lawsuit) alleging patent claim infringed making, using, selling, offering sale, importing Program portion .","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_11-patents","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"11. Patents","title":"GNU General Public License","text":"“contributor” copyright holder authorizes use License Program work Program based. work thus licensed called contributor’s “contributor version”. contributor’s “essential patent claims” patent claims owned controlled contributor, whether already acquired hereafter acquired, infringed manner, permitted License, making, using, selling contributor version, include claims infringed consequence modification contributor version. purposes definition, “control” includes right grant patent sublicenses manner consistent requirements License. contributor grants non-exclusive, worldwide, royalty-free patent license contributor’s essential patent claims, make, use, sell, offer sale, import otherwise run, modify propagate contents contributor version. following three paragraphs, “patent license” express agreement commitment, however denominated, enforce patent (express permission practice patent covenant sue patent infringement). “grant” patent license party means make agreement commitment enforce patent party. convey covered work, knowingly relying patent license, Corresponding Source work available anyone copy, free charge terms License, publicly available network server readily accessible means, must either (1) cause Corresponding Source available, (2) arrange deprive benefit patent license particular work, (3) arrange, manner consistent requirements License, extend patent license downstream recipients. “Knowingly relying” means actual knowledge , patent license, conveying covered work country, recipient’s use covered work country, infringe one identifiable patents country reason believe valid. , pursuant connection single transaction arrangement, convey, propagate procuring conveyance , covered work, grant patent license parties receiving covered work authorizing use, propagate, modify convey specific copy covered work, patent license grant automatically extended recipients covered work works based . patent license “discriminatory” include within scope coverage, prohibits exercise , conditioned non-exercise one rights specifically granted License. may convey covered work party arrangement third party business distributing software, make payment third party based extent activity conveying work, third party grants, parties receive covered work , discriminatory patent license () connection copies covered work conveyed (copies made copies), (b) primarily connection specific products compilations contain covered work, unless entered arrangement, patent license granted, prior 28 March 2007. Nothing License shall construed excluding limiting implied license defenses infringement may otherwise available applicable patent law.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_12-no-surrender-of-others-freedom","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"12. No Surrender of Others’ Freedom","title":"GNU General Public License","text":"conditions imposed (whether court order, agreement otherwise) contradict conditions License, excuse conditions License. convey covered work satisfy simultaneously obligations License pertinent obligations, consequence may convey . example, agree terms obligate collect royalty conveying convey Program, way satisfy terms License refrain entirely conveying Program.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_13-use-with-the-gnu-affero-general-public-license","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"13. Use with the GNU Affero General Public License","title":"GNU General Public License","text":"Notwithstanding provision License, permission link combine covered work work licensed version 3 GNU Affero General Public License single combined work, convey resulting work. terms License continue apply part covered work, special requirements GNU Affero General Public License, section 13, concerning interaction network apply combination .","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_14-revised-versions-of-this-license","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"14. Revised Versions of this License","title":"GNU General Public License","text":"Free Software Foundation may publish revised /new versions GNU General Public License time time. new versions similar spirit present version, may differ detail address new problems concerns. version given distinguishing version number. Program specifies certain numbered version GNU General Public License “later version” applies , option following terms conditions either numbered version later version published Free Software Foundation. Program specify version number GNU General Public License, may choose version ever published Free Software Foundation. Program specifies proxy can decide future versions GNU General Public License can used, proxy’s public statement acceptance version permanently authorizes choose version Program. Later license versions may give additional different permissions. However, additional obligations imposed author copyright holder result choosing follow later version.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_15-disclaimer-of-warranty","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"15. Disclaimer of Warranty","title":"GNU General Public License","text":"WARRANTY PROGRAM, EXTENT PERMITTED APPLICABLE LAW. EXCEPT OTHERWISE STATED WRITING COPYRIGHT HOLDERS /PARTIES PROVIDE PROGRAM “” WITHOUT WARRANTY KIND, EITHER EXPRESSED IMPLIED, INCLUDING, LIMITED , IMPLIED WARRANTIES MERCHANTABILITY FITNESS PARTICULAR PURPOSE. ENTIRE RISK QUALITY PERFORMANCE PROGRAM . PROGRAM PROVE DEFECTIVE, ASSUME COST NECESSARY SERVICING, REPAIR CORRECTION.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_16-limitation-of-liability","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"16. Limitation of Liability","title":"GNU General Public License","text":"EVENT UNLESS REQUIRED APPLICABLE LAW AGREED WRITING COPYRIGHT HOLDER, PARTY MODIFIES /CONVEYS PROGRAM PERMITTED , LIABLE DAMAGES, INCLUDING GENERAL, SPECIAL, INCIDENTAL CONSEQUENTIAL DAMAGES ARISING USE INABILITY USE PROGRAM (INCLUDING LIMITED LOSS DATA DATA RENDERED INACCURATE LOSSES SUSTAINED THIRD PARTIES FAILURE PROGRAM OPERATE PROGRAMS), EVEN HOLDER PARTY ADVISED POSSIBILITY DAMAGES.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_17-interpretation-of-sections-15-and-16","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"17. Interpretation of Sections 15 and 16","title":"GNU General Public License","text":"disclaimer warranty limitation liability provided given local legal effect according terms, reviewing courts shall apply local law closely approximates absolute waiver civil liability connection Program, unless warranty assumption liability accompanies copy Program return fee. END TERMS CONDITIONS","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"how-to-apply-these-terms-to-your-new-programs","dir":"","previous_headings":"","what":"How to Apply These Terms to Your New Programs","title":"GNU General Public License","text":"develop new program, want greatest possible use public, best way achieve make free software everyone can redistribute change terms. , attach following notices program. safest attach start source file effectively state exclusion warranty; file least “copyright” line pointer full notice found. Also add information contact electronic paper mail. program terminal interaction, make output short notice like starts interactive mode: hypothetical commands show w show c show appropriate parts General Public License. course, program’s commands might different; GUI interface, use “box”. also get employer (work programmer) school, , sign “copyright disclaimer” program, necessary. information , apply follow GNU GPL, see . GNU General Public License permit incorporating program proprietary programs. program subroutine library, may consider useful permit linking proprietary applications library. want , use GNU Lesser General Public License instead License. first, please read .","code":" Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details."},{"path":"https://vsp.berlin/matsim-r/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Billy Charlton. Author, maintainer. Oleksandr Soboliev. Author.","code":""},{"path":"https://vsp.berlin/matsim-r/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Charlton B, Soboliev O (2023). matsim: R library interfacing MATSim agent-based microsimulation model. R package version 0.1.8, https://github.com/matsim-vsp/matsim-r.","code":"@Manual{, title = {matsim: R library for interfacing with MATSim agent-based microsimulation model}, author = {Billy Charlton and Oleksandr Soboliev}, year = {2023}, note = {R package version 0.1.8}, url = {https://github.com/matsim-vsp/matsim-r}, }"},{"path":"https://vsp.berlin/matsim-r/index.html","id":"matsim-r-support-package","dir":"","previous_headings":"","what":"R library for interfacing with MATSim agent-based microsimulation model","title":"R library for interfacing with MATSim agent-based microsimulation model","text":"MATSim https://matsim.org agent-based microsimulation package large-scape transport simulations. package mimics functionality Python matsim-tools package, eventually support standard MATSim networks, plans events. Currently network files supported, many summarization plots based MATSim standard output_trips file. One useful command builds SimWrapper dashboard standard MATSim output_trips.xml.gz file: R -e \"matsim::prepareSimwrapperDashboardFromFolder()\" work preliminary ongoing – submissions welcome!","code":""},{"path":"https://vsp.berlin/matsim-r/index.html","id":"install","dir":"","previous_headings":"","what":"Install","title":"R library for interfacing with MATSim agent-based microsimulation model","text":"can install package right now: install.packages(\"devtools\") devtools::install_github(\"matsim-vsp/matsim-r\") install package specific branch use: devtools::install_github(\"matsim-vsp/matsim-r\",ref=\"{name branch}\")","code":""},{"path":"https://vsp.berlin/matsim-r/index.html","id":"installing-from-gz-archive","dir":"","previous_headings":"Install","what":"Installing from .gz archive","title":"R library for interfacing with MATSim agent-based microsimulation model","text":"Instead using devtools can also install directly source archive: install.packages(\"matsim-r.tar.gz\", type=\"source\", repos=NULL)","code":""},{"path":"https://vsp.berlin/matsim-r/index.html","id":"documentation-build-instructions","dir":"","previous_headings":"","what":"Documentation build instructions","title":"R library for interfacing with MATSim agent-based microsimulation model","text":"Run GNU Make build docs whenever source files R/ change. create man pages well fancy HTML docs/ folder , build : devtools::document() builds docs NAMESPACE pkgdown::build_site() builds HTML docs","code":""},{"path":"https://vsp.berlin/matsim-r/reference/compareAverageTravelWait.html","id":null,"dir":"Reference","previous_headings":"","what":"Bar Chart with main_mode on x-axis and average travel/wait time on y-axis — compareAverageTravelWait","title":"Bar Chart with main_mode on x-axis and average travel/wait time on y-axis — compareAverageTravelWait","text":"Takes Table trips_output (readTripsTable()), plot bar chart values represent time spent traveling/waiting Using parameters unite.columns, specific columns given, unite 1 mode name united.name(default 'united')","code":""},{"path":"https://vsp.berlin/matsim-r/reference/compareAverageTravelWait.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Bar Chart with main_mode on x-axis and average travel/wait time on y-axis — compareAverageTravelWait","text":"","code":"compareAverageTravelWait( tripsTable1, tripsTable2, unite.columns = character(0), united.name = \"united\", dump.output.to = matsimDumpOutputDirectory, only.files = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/compareAverageTravelWait.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Bar Chart with main_mode on x-axis and average travel/wait time on y-axis — compareAverageTravelWait","text":"tripsTable1 tible trips_output (readTripsTable()) tripsTable2 tible trips_output (readTripsTable()) unite.columns vector character strings, represent patterns columns united, changes name transport modes tibble copy united.name = \"united\" matches PATTERNS given unite.columns united.name character string, columns united, can specify name resulting column chart dump.output.folder saves configures yaml simwrapper dashboard. folder png plot stored .files boolean, represent plotting inside project needed, default FALSE - means function gives plot plot_ly","code":""},{"path":"https://vsp.berlin/matsim-r/reference/compareAverageTravelWait.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Bar Chart with main_mode on x-axis and average travel/wait time on y-axis — compareAverageTravelWait","text":"Bar Chart plot average time spent travel/wait","code":""},{"path":"https://vsp.berlin/matsim-r/reference/compareBasePolicyOutput.html","id":null,"dir":"Reference","previous_headings":"","what":"Chooses a function to compare output_trips from the folders.\nbaseFolder contains all base outputs, policyFolder contains all policy outputs. — compareBasePolicyOutput","title":"Chooses a function to compare output_trips from the folders.\nbaseFolder contains all base outputs, policyFolder contains all policy outputs. — compareBasePolicyOutput","text":"Chooses function compare output_trips folders. baseFolder contains base outputs, policyFolder contains policy outputs.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/compareBasePolicyOutput.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Chooses a function to compare output_trips from the folders.\nbaseFolder contains all base outputs, policyFolder contains all policy outputs. — compareBasePolicyOutput","text":"","code":"compareBasePolicyOutput( baseFolder, policyFolder, dump.output.to = matsimDumpOutputDirectory )"},{"path":"https://vsp.berlin/matsim-r/reference/compareBasePolicyOutput.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Chooses a function to compare output_trips from the folders.\nbaseFolder contains all base outputs, policyFolder contains all policy outputs. — compareBasePolicyOutput","text":"baseFolder specifies data source folder multiple base output_trips policyFolder specifies data source folder multiple policy output_trips dump.output.saves result comparisons base policy. now creates plotModalShiftBar() output_trips","code":""},{"path":"https://vsp.berlin/matsim-r/reference/compareBasePolicyOutput.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Chooses a function to compare output_trips from the folders.\nbaseFolder contains all base outputs, policyFolder contains all policy outputs. — compareBasePolicyOutput","text":"list tibbles, list base policy output_trips tibble","code":""},{"path":"https://vsp.berlin/matsim-r/reference/compareBasePolicyShapeOutput.html","id":null,"dir":"Reference","previous_headings":"","what":"Chooses a function to compare output_trips from the folders.\nbaseFolder contains all base outputs, policyFolder contains all policy outputs. — compareBasePolicyShapeOutput","title":"Chooses a function to compare output_trips from the folders.\nbaseFolder contains all base outputs, policyFolder contains all policy outputs. — compareBasePolicyShapeOutput","text":"Chooses function compare output_trips folders. baseFolder contains base outputs, policyFolder contains policy outputs.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/compareBasePolicyShapeOutput.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Chooses a function to compare output_trips from the folders.\nbaseFolder contains all base outputs, policyFolder contains all policy outputs. — compareBasePolicyShapeOutput","text":"","code":"compareBasePolicyShapeOutput( baseFolder, policyFolder, shapeFilePath, crs, dump.output.to = matsimDumpOutputDirectory )"},{"path":"https://vsp.berlin/matsim-r/reference/compareBasePolicyShapeOutput.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Chooses a function to compare output_trips from the folders.\nbaseFolder contains all base outputs, policyFolder contains all policy outputs. — compareBasePolicyShapeOutput","text":"baseFolder specifies data source folder multiple base output_trips policyFolder specifies data source folder multiple policy output_trips shapeFilePath specifies shapeFile used comparison crs numeric EPSG code proj4string, can found network/config file output directory MATSim simulation dump.output.saves result comparisons base policy. now creates plotModalShiftBar() output_trips","code":""},{"path":"https://vsp.berlin/matsim-r/reference/compareBasePolicyShapeOutput.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Chooses a function to compare output_trips from the folders.\nbaseFolder contains all base outputs, policyFolder contains all policy outputs. — compareBasePolicyShapeOutput","text":"list tibbles, list base policy output_trips tibble","code":""},{"path":"https://vsp.berlin/matsim-r/reference/compareModalDistanceDistribution.html","id":null,"dir":"Reference","previous_headings":"","what":"Bar Chart with distance travelled on x-axis and difference of number of trips on y-axis — compareModalDistanceDistribution","title":"Bar Chart with distance travelled on x-axis and difference of number of trips on y-axis — compareModalDistanceDistribution","text":"Takes 2 Tables trips_output (readTripsTable()), plot bar chart values represent difference number trips tripsTable2 tripsTable1 ~ distance travelled Using parameters unite.columns, specific columns given, unite 1 mode name united.name(default 'united')","code":""},{"path":"https://vsp.berlin/matsim-r/reference/compareModalDistanceDistribution.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Bar Chart with distance travelled on x-axis and difference of number of trips on y-axis — compareModalDistanceDistribution","text":"","code":"compareModalDistanceDistribution( tripsTable1, tripsTable2, unite.columns = character(0), united.name = \"united\", dump.output.to = matsimDumpOutputDirectory, only.files = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/compareModalDistanceDistribution.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Bar Chart with distance travelled on x-axis and difference of number of trips on y-axis — compareModalDistanceDistribution","text":"tripsTable1 tible trips_output (readTripsTable()), number trips table extracted number trips tripsTable1 tripsTable2 tible trips_output (readTripsTable()), number trips table number trips tripsTable1 extracted unite.columns vector character strings, represent patterns columns united, changes name transport modes tibble copy united.name = \"united\" matches PATTERNS given unite.columns united.name character string, columns united, can specify name resulting column chart dump.output.folder saves configures yaml simwrapper dashboard. folder png plot stored .files boolean, represent plotting inside project needed, default FALSE - means function gives plot plot_ly","code":""},{"path":"https://vsp.berlin/matsim-r/reference/compareModalDistanceDistribution.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Bar Chart with distance travelled on x-axis and difference of number of trips on y-axis — compareModalDistanceDistribution","text":"Bar Chart plot count trips among distance travelled","code":""},{"path":"https://vsp.berlin/matsim-r/reference/compareTripTypesBarChart.html","id":null,"dir":"Reference","previous_headings":"","what":"Creates BarChart of changing trip types(originating,transit etc) between 2 tables\nand saves output to dump.output.to — compareTripTypesBarChart","title":"Creates BarChart of changing trip types(originating,transit etc) between 2 tables\nand saves output to dump.output.to — compareTripTypesBarChart","text":"Creates BarChart changing trip types(originating,transit etc) 2 tables saves output dump.output.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/compareTripTypesBarChart.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Creates BarChart of changing trip types(originating,transit etc) between 2 tables\nand saves output to dump.output.to — compareTripTypesBarChart","text":"","code":"compareTripTypesBarChart( tripsTable1, tripsTable2, shapeTable, crs, dump.output.to = matsimDumpOutputDirectory )"},{"path":"https://vsp.berlin/matsim-r/reference/compareTripTypesBarChart.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Creates BarChart of changing trip types(originating,transit etc) between 2 tables\nand saves output to dump.output.to — compareTripTypesBarChart","text":"tripsTable1 tibble trips_output (readTripsTable(),f.e. base case) tripsTable2 tibble trips_output (readTripsTable(),f.e. policy case) shapeTable sf object(data.frame geometries), can received using st_read(path_to_geographical_file) crs numeric EPSG code proj4string, can found network file output directory MATSim simulation dump.output.folder saves resulting image BarChart","code":""},{"path":"https://vsp.berlin/matsim-r/reference/compareTripTypesBarChart.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Creates BarChart of changing trip types(originating,transit etc) between 2 tables\nand saves output to dump.output.to — compareTripTypesBarChart","text":"plot percentage type trips 2 tables","code":""},{"path":"https://vsp.berlin/matsim-r/reference/createCountScatterPlot.html","id":null,"dir":"Reference","previous_headings":"","what":"Creates a Via-Style scatterplot for each run — createCountScatterPlot","title":"Creates a Via-Style scatterplot for each run — createCountScatterPlot","text":"Takes tibble mergeCountsAndLinks. scatterplot counts x axis matsim dtv y axis created colored road type. Lower upper Limits define section considered 'exact' estimation. Limits defined custom formulas.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/createCountScatterPlot.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Creates a Via-Style scatterplot for each run — createCountScatterPlot","text":"","code":"createCountScatterPlot( joinedFrame, ll = ~x * 0.8 - 200, ul = ~x * 1.2 + 200, threshold = 100 )"},{"path":"https://vsp.berlin/matsim-r/reference/createCountScatterPlot.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Creates a Via-Style scatterplot for each run — createCountScatterPlot","text":"joinedFrame tibble mergeCountsAndLinks ll Formula calculate lower limit quality label 'exact', default = 0.8*x - 200 ul Formula calculate lower limit quality label 'exact', default = 1.2*x + 200 threshold Threshold data scaled log10.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/createCountScatterPlot.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Creates a Via-Style scatterplot for each run — createCountScatterPlot","text":"ggplot Scatterplotplot, can adjusted, needed.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/createCountScatterPlot.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Creates a Via-Style scatterplot for each run — createCountScatterPlot","text":"function calls matsim-r function processDtvEstimationQuality handeling limits.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/deriveODMatrix.html","id":null,"dir":"Reference","previous_headings":"","what":"Creates an instance of ODMatrix(origin/destination) in conventional form or for the simwrapper — deriveODMatrix","title":"Creates an instance of ODMatrix(origin/destination) in conventional form or for the simwrapper — deriveODMatrix","text":"Creates instance ODMatrix(origin/destination) conventional form simwrapper","code":""},{"path":"https://vsp.berlin/matsim-r/reference/deriveODMatrix.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Creates an instance of ODMatrix(origin/destination) in conventional form or for the simwrapper — deriveODMatrix","text":"","code":"deriveODMatrix( tripsTable, shapePath, crs, dump.output.to = matsimDumpOutputDirectory, simwrapper = FALSE, colnames = \"numeric\", outer = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/deriveODMatrix.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Creates an instance of ODMatrix(origin/destination) in conventional form or for the simwrapper — deriveODMatrix","text":"tripsTable table output trips(readTripsTable) path trips_output file shapePath full path shapefile (simwrapper TRUE, folder shapeFile contain also .dbf name) crs numeric EPSG code proj4string, can found network file output directory MATSim simulation dump.output.path folder save csv file ODMatrix simwrapper create output simwrapper form set path shapefile colnames specific shapefile contains known columns, specified name columns OD. given get numeric values outer logical represent table contain outside flow shape, ","code":""},{"path":"https://vsp.berlin/matsim-r/reference/deriveODMatrix.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Creates an instance of ODMatrix(origin/destination) in conventional form or for the simwrapper — deriveODMatrix","text":"tibble origin/destination matrix","code":""},{"path":"https://vsp.berlin/matsim-r/reference/filterByRegion.html","id":null,"dir":"Reference","previous_headings":"","what":"Filtering of trips_table(from readTripsTable) depending on how they located in given shape — filterByRegion","title":"Filtering of trips_table(from readTripsTable) depending on how they located in given shape — filterByRegion","text":"Takes trips_table shapeTable(sf object file representing geographical data, can received using function st_read(path_to_file). Please aware filterByRegion currently works, one geometry loaded.) transforms objects match mutual CRS(network.xml MATSimOutputDirectory) filters trips table depending *.inshape flags: start.inshape = TRUE & end.inshape = TRUE return table contains trips inside given shape start.inshape = TRUE & end.inshape = FALSE return table contains trips starts shape ends shape start.inshape = FALSE & end.inshape = TRUE return table contains trips ends shape starts shape start.inshape = FALSE & end.inshape = FALSE return table contains trips starts ends given shape","code":""},{"path":"https://vsp.berlin/matsim-r/reference/filterByRegion.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Filtering of trips_table(from readTripsTable) depending on how they located in given shape — filterByRegion","text":"","code":"filterByRegion( tripsTable, shapeTable, crs, start.inshape = TRUE, end.inshape = TRUE )"},{"path":"https://vsp.berlin/matsim-r/reference/filterByRegion.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Filtering of trips_table(from readTripsTable) depending on how they located in given shape — filterByRegion","text":"tripsTable tibble trips_output (readTripsTable()) shapeTable sf object(data.frame geometries), can received using st_read(path_to_geographical_file) crs numeric EPSG code proj4string, can found network file output directory MATSim simulation start.inshape bool, defines trips conclude (see Description) end.inshape bool, defines trips conclude (see Description)","code":""},{"path":"https://vsp.berlin/matsim-r/reference/filterByRegion.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Filtering of trips_table(from readTripsTable) depending on how they located in given shape — filterByRegion","text":"tibble, filtered trips depending shapeTable special flags (see Description)","code":""},{"path":"https://vsp.berlin/matsim-r/reference/generateXYHexagonYaml.html","id":null,"dir":"Reference","previous_headings":"","what":"Creates/adds XY hexagon definition of output trips to a summary dashboard — generateXYHexagonYaml","title":"Creates/adds XY hexagon definition of output trips to a summary dashboard — generateXYHexagonYaml","text":"Creates/adds XY hexagon definition output trips summary dashboard","code":""},{"path":"https://vsp.berlin/matsim-r/reference/generateXYHexagonYaml.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Creates/adds XY hexagon definition of output trips to a summary dashboard — generateXYHexagonYaml","text":"","code":"generateXYHexagonYaml( pathToOutputTrips, crs, dump.output.to = matsimDumpOutputDirectory )"},{"path":"https://vsp.berlin/matsim-r/reference/generateXYHexagonYaml.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Creates/adds XY hexagon definition of output trips to a summary dashboard — generateXYHexagonYaml","text":"pathToOutputTrips specifies path data source output_trips crs specifies coordinate reference system output_trips dump.output.path folder dashboard","code":""},{"path":"https://vsp.berlin/matsim-r/reference/generateXYHexagonYaml.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Creates/adds XY hexagon definition of output trips to a summary dashboard — generateXYHexagonYaml","text":"changed file","code":""},{"path":"https://vsp.berlin/matsim-r/reference/generate_html_docs.html","id":null,"dir":"Reference","previous_headings":"","what":"Generate html docs from roxygen2 docs — generate_html_docs","title":"Generate html docs from roxygen2 docs — generate_html_docs","text":"https://stackoverflow.com/questions/30897301/export-r-package-documentation---web-page","code":""},{"path":"https://vsp.berlin/matsim-r/reference/generate_html_docs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Generate html docs from roxygen2 docs — generate_html_docs","text":"","code":"generate_html_docs(pkg, links = tools::findHTMLlinks())"},{"path":"https://vsp.berlin/matsim-r/reference/generate_html_docs.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Generate html docs from roxygen2 docs — generate_html_docs","text":"exported, internal use ","code":""},{"path":"https://vsp.berlin/matsim-r/reference/getCrsFromConfig.html","id":null,"dir":"Reference","previous_headings":"","what":"Reads an coordinate referenec system of MATSim output directory\nfrom output_config.xml — getCrsFromConfig","title":"Reads an coordinate referenec system of MATSim output directory\nfrom output_config.xml — getCrsFromConfig","text":"Reads coordinate referenec system MATSim output directory output_config.xml","code":""},{"path":"https://vsp.berlin/matsim-r/reference/getCrsFromConfig.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Reads an coordinate referenec system of MATSim output directory\nfrom output_config.xml — getCrsFromConfig","text":"","code":"getCrsFromConfig(folder)"},{"path":"https://vsp.berlin/matsim-r/reference/getCrsFromConfig.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Reads an coordinate referenec system of MATSim output directory\nfrom output_config.xml — getCrsFromConfig","text":"folder specifies path find config","code":""},{"path":"https://vsp.berlin/matsim-r/reference/getCrsFromConfig.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Reads an coordinate referenec system of MATSim output directory\nfrom output_config.xml — getCrsFromConfig","text":"code coordinate reference system","code":""},{"path":"https://vsp.berlin/matsim-r/reference/loadNetwork.html","id":null,"dir":"Reference","previous_headings":"","what":"Load MATSim network into memory — loadNetwork","title":"Load MATSim network into memory — loadNetwork","text":"Loads MATSim XML network file, creating nodes tibble links tibble. node link attribute records network stored additional columns respective node link tibbles.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/loadNetwork.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Load MATSim network into memory — loadNetwork","text":"","code":"loadNetwork(filename)"},{"path":"https://vsp.berlin/matsim-r/reference/loadNetwork.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Load MATSim network into memory — loadNetwork","text":"filename File load. Can XML gzipped XML","code":""},{"path":"https://vsp.berlin/matsim-r/reference/loadNetwork.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Load MATSim network into memory — loadNetwork","text":"\"nodes\" \"links\" tibbles list object.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/loadNetwork.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Load MATSim network into memory — loadNetwork","text":"links table automatically joined nodes table node x/y coordinates (node attributes) available links table without additional processing.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/mergeCountsAndLinks.html","id":null,"dir":"Reference","previous_headings":"","what":"Load Counts, a limited number of Linkstats and Network links as joined tibble into memory — mergeCountsAndLinks","title":"Load Counts, a limited number of Linkstats and Network links as joined tibble into memory — mergeCountsAndLinks","text":"Function join counts, network links several matsim link stats. Data can aggregated filtered time network mode.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/mergeCountsAndLinks.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Load Counts, a limited number of Linkstats and Network links as joined tibble into memory — mergeCountsAndLinks","text":"","code":"mergeCountsAndLinks( counts, network, linkStats, networkModes = c(\"car\"), aggr_to = c(\"day\", \"hour\"), earliest = 0, latest = 86400 )"},{"path":"https://vsp.berlin/matsim-r/reference/mergeCountsAndLinks.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Load Counts, a limited number of Linkstats and Network links as joined tibble into memory — mergeCountsAndLinks","text":"counts Tibble counts data network Tibble network nodes links linkStats List link stats tibbles networkModes vector network modes, needed analysis aggr_to Determinates data aggregated hour values DTV, can either \"day\" \"hour\" earliest Lower limit filter link stats time, default 0 latest Upper limit filter link stats time, default 86400 (midnight)","code":""},{"path":"https://vsp.berlin/matsim-r/reference/mergeCountsAndLinks.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Load Counts, a limited number of Linkstats and Network links as joined tibble into memory — mergeCountsAndLinks","text":"Long-format tibble MATSim link id key (\"loc_id\"), traffic volume MATSim runs link type","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotActivityEndTimes.html","id":null,"dir":"Reference","previous_headings":"","what":"Line plot that shows the number of activities ending at a given time, per activity type.\nThe activity end time is derived from the departure time in the given trips tibble. — plotActivityEndTimes","title":"Line plot that shows the number of activities ending at a given time, per activity type.\nThe activity end time is derived from the departure time in the given trips tibble. — plotActivityEndTimes","text":"Takes Table trips_output (readTripsTable()), make line plot values represent number activities ending specific time. Using parameters unite.columns, specific columns given, unite 1 mode name united.name(default 'united')","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotActivityEndTimes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Line plot that shows the number of activities ending at a given time, per activity type.\nThe activity end time is derived from the departure time in the given trips tibble. — plotActivityEndTimes","text":"","code":"plotActivityEndTimes( tripsTable, unite.columns = character(0), united.name = \"united\", dump.output.to = matsimDumpOutputDirectory, only.files = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/plotActivityEndTimes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Line plot that shows the number of activities ending at a given time, per activity type.\nThe activity end time is derived from the departure time in the given trips tibble. — plotActivityEndTimes","text":"tripsTable tible trips_output (readTripsTable()) unite.columns vector character strings, represent patterns columns united, changes name activity types tibble copy united.name = \"united\" matches PATTERNS given unite.columns united.name character string, columns united, can specify name resulting column chart dump.output.folder saves configures yaml simwrapper dashboard. folder png plot stored .files boolean, represent plotting inside project needed, default FALSE - means function gives plot plot_ly","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotActivityEndTimes.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Line plot that shows the number of activities ending at a given time, per activity type.\nThe activity end time is derived from the departure time in the given trips tibble. — plotActivityEndTimes","text":"Line plot departure time x-axis number start activities y-axis","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotArrivalTimesPerTripPurpose.html","id":null,"dir":"Reference","previous_headings":"","what":"This function plots the number of trips ending per trip purpose over time. The trip purpose corresponds to the activity type of the destination activity of a given trip.\nThus, the y-axis of the plot can also be interpreted as the number of activities starting (based on the assumption that trip end time = activity start time). — plotArrivalTimesPerTripPurpose","title":"This function plots the number of trips ending per trip purpose over time. The trip purpose corresponds to the activity type of the destination activity of a given trip.\nThus, the y-axis of the plot can also be interpreted as the number of activities starting (based on the assumption that trip end time = activity start time). — plotArrivalTimesPerTripPurpose","text":"Takes Table trips_output (readTripsTable()), make line plot values represent count destination activities specific arrival time Using parameters unite.columns, specific columns given, unite 1 mode name united.name(default 'united')","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotArrivalTimesPerTripPurpose.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"This function plots the number of trips ending per trip purpose over time. The trip purpose corresponds to the activity type of the destination activity of a given trip.\nThus, the y-axis of the plot can also be interpreted as the number of activities starting (based on the assumption that trip end time = activity start time). — plotArrivalTimesPerTripPurpose","text":"","code":"plotArrivalTimesPerTripPurpose( tripsTable, unite.columns = character(0), united.name = \"united\", dump.output.to = matsimDumpOutputDirectory, only.files = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/plotArrivalTimesPerTripPurpose.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"This function plots the number of trips ending per trip purpose over time. The trip purpose corresponds to the activity type of the destination activity of a given trip.\nThus, the y-axis of the plot can also be interpreted as the number of activities starting (based on the assumption that trip end time = activity start time). — plotArrivalTimesPerTripPurpose","text":"tripsTable tibble trips_output (readTripsTable()) unite.columns vector character strings, represent patterns columns united, changes name activity types tibble copy united.name = \"united\" matches PATTERNS given unite.columns united.name character string, columns united, can specify name resulting column plot dump.output.folder saves configures yaml simwrapper dashboard. folder png plot stored .files boolean, represent plotting inside project needed, default FALSE - means function gives plot plot_ly","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotArrivalTimesPerTripPurpose.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"This function plots the number of trips ending per trip purpose over time. The trip purpose corresponds to the activity type of the destination activity of a given trip.\nThus, the y-axis of the plot can also be interpreted as the number of activities starting (based on the assumption that trip end time = activity start time). — plotArrivalTimesPerTripPurpose","text":"Line plot arrival time x-axis number end activities y-axis","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotAverageTravelWait.html","id":null,"dir":"Reference","previous_headings":"","what":"Bar Chart with main_mode on x-axis and average travel/wait time on y-axis — plotAverageTravelWait","title":"Bar Chart with main_mode on x-axis and average travel/wait time on y-axis — plotAverageTravelWait","text":"Takes Table trips_output (readTripsTable()), plot bar chart values represent time spent traveling/waiting Using parameters unite.columns, specific columns given, unite 1 mode name united.name(default 'united')","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotAverageTravelWait.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Bar Chart with main_mode on x-axis and average travel/wait time on y-axis — plotAverageTravelWait","text":"","code":"plotAverageTravelWait( tripsTable, unite.columns = character(0), united.name = \"united\", dump.output.to = matsimDumpOutputDirectory, only.files = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/plotAverageTravelWait.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Bar Chart with main_mode on x-axis and average travel/wait time on y-axis — plotAverageTravelWait","text":"tripsTable tible trips_output (readTripsTable()) unite.columns vector character strings, represent patterns columns united, changes name transport modes tibble copy united.name = \"united\" matches PATTERNS given unite.columns united.name character string, columns united, can specify name resulting column chart dump.output.folder saves configures yaml simwrapper dashboard. folder png plot stored .files boolean, represent plotting inside project needed, default FALSE - means function gives plot plot_ly","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotAverageTravelWait.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Bar Chart with main_mode on x-axis and average travel/wait time on y-axis — plotAverageTravelWait","text":"Bar Chart plot average time spent travel/wait","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotDepartureTimesPerTripPurpose.html","id":null,"dir":"Reference","previous_headings":"","what":"This function plots the number of trips starting per trip purpose over time. The trip purpose corresponds to the activity type of the destination activity of a given trip. — plotDepartureTimesPerTripPurpose","title":"This function plots the number of trips starting per trip purpose over time. The trip purpose corresponds to the activity type of the destination activity of a given trip. — plotDepartureTimesPerTripPurpose","text":"Takes Table trips_output (readTripsTable()), make line plot values represent count destination activities specific arrival time Using parameters unite.columns, specific columns given, unite 1 mode name united.name(default 'united')","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotDepartureTimesPerTripPurpose.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"This function plots the number of trips starting per trip purpose over time. The trip purpose corresponds to the activity type of the destination activity of a given trip. — plotDepartureTimesPerTripPurpose","text":"","code":"plotDepartureTimesPerTripPurpose( tripsTable, unite.columns = character(0), united.name = \"united\", dump.output.to = matsimDumpOutputDirectory, only.files = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/plotDepartureTimesPerTripPurpose.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"This function plots the number of trips starting per trip purpose over time. The trip purpose corresponds to the activity type of the destination activity of a given trip. — plotDepartureTimesPerTripPurpose","text":"tripsTable tibble trips_output (readTripsTable()) unite.columns vector character strings, represent patterns columns united, changes name activity types tibble copy united.name = \"united\" matches PATTERNS given unite.columns united.name character string, columns united, can specify name resulting column plot dump.output.folder saves configures yaml simwrapper dashboard. folder png plot stored .files boolean, represent plotting inside project needed, default FALSE - means function gives plot plot_ly","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotDepartureTimesPerTripPurpose.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"This function plots the number of trips starting per trip purpose over time. The trip purpose corresponds to the activity type of the destination activity of a given trip. — plotDepartureTimesPerTripPurpose","text":"Line plot arrival time x-axis number end activities y-axis","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotDistanceTraveledByType.html","id":null,"dir":"Reference","previous_headings":"","what":"Bar Chart with tripType on x-axis and travelled distance on y-axis — plotDistanceTraveledByType","title":"Bar Chart with tripType on x-axis and travelled distance on y-axis — plotDistanceTraveledByType","text":"Takes Table trips_output (readTripsTable()), plot bar chart values represent travelled distance tripType related shapeTable","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotDistanceTraveledByType.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Bar Chart with tripType on x-axis and travelled distance on y-axis — plotDistanceTraveledByType","text":"","code":"plotDistanceTraveledByType( tripsTable, shapeTable, crs, dump.output.to = matsimDumpOutputDirectory )"},{"path":"https://vsp.berlin/matsim-r/reference/plotDistanceTraveledByType.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Bar Chart with tripType on x-axis and travelled distance on y-axis — plotDistanceTraveledByType","text":"tripsTable tible trips_output (readTripsTable()) shapeTable sf object(data.frame geometries), can received using st_read(path_to_geographical_file) crs numeric EPSG code proj4string, can found network file output directory MATSim simulation dump.output.folder saves configures yaml simwrapper dashboard. folder png plot stored","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotDistanceTraveledByType.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Bar Chart with tripType on x-axis and travelled distance on y-axis — plotDistanceTraveledByType","text":"Bar Chart plot average time spent travel/wait","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotEndActCountByArrTime.html","id":null,"dir":"Reference","previous_headings":"","what":"Scatter plot with arrival time x-axis and number end activities on y-axis — plotEndActCountByArrTime","title":"Scatter plot with arrival time x-axis and number end activities on y-axis — plotEndActCountByArrTime","text":"Takes Table trips_output (readTripsTable()), plot scatter plot values represent count end activities specific arrival time Using parameters unite.columns, specific columns given, unite 1 mode name united.name(default 'united')","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotEndActCountByArrTime.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Scatter plot with arrival time x-axis and number end activities on y-axis — plotEndActCountByArrTime","text":"","code":"plotEndActCountByArrTime( tripsTable, unite.columns = character(0), united.name = \"united\", dump.output.to = matsimDumpOutputDirectory, only.files = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/plotEndActCountByArrTime.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Scatter plot with arrival time x-axis and number end activities on y-axis — plotEndActCountByArrTime","text":"tripsTable tible trips_output (readTripsTable()) unite.columns vector character strings, represent patterns columns united, changes name transport modes tibble copy united.name = \"united\" matches PATTERNS given unite.columns united.name character string, columns united, can specify name resulting column chart dump.output.folder saves configures yaml simwrapper dashboard. folder png plot stored .files boolean, represent plotting inside project needed, default FALSE - means function gives plot plot_ly","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotEndActCountByArrTime.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Scatter plot with arrival time x-axis and number end activities on y-axis — plotEndActCountByArrTime","text":"Bar Chart plot distance traveled per mode","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotMapWithTrips.html","id":null,"dir":"Reference","previous_headings":"","what":"Plots result of filtered trips on the map (from shape) — plotMapWithTrips","title":"Plots result of filtered trips on the map (from shape) — plotMapWithTrips","text":"Takes trips_table shapeTable(sf object file representing geographical data, can received using function st_read(path_to_file)) transforms objects match mutual CRS(network.xml MATSimOutputDirectory) filters trips table depending *.inshape flags: start.inshape = TRUE & end.inshape = TRUE return table contains trips inside given shape start.inshape = TRUE & end.inshape = FALSE return table contains trips starts shape ends shape start.inshape = FALSE & end.inshape = TRUE return table contains trips ends shape starts shape start.inshape = FALSE & end.inshape = FALSE return table contains trips starts ends given shape result filtering plotted map shapeTable green points startpoints trip red points endpoints trip","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotMapWithTrips.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plots result of filtered trips on the map (from shape) — plotMapWithTrips","text":"","code":"plotMapWithTrips( table, shapeTable, crs, start.inshape = TRUE, end.inshape = TRUE, optimized = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/plotMapWithTrips.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plots result of filtered trips on the map (from shape) — plotMapWithTrips","text":"table tibble trips_output (readTripsTable()) shapeTable sf object(data.frame geometries), can received using st_read(path_to_geographical_file) crs numeric EPSG code proj4string, can found network file output directory MATSim simulation start.inshape bool, defines trips conclude (see Description) end.inshape bool, defines trips conclude (see Description) optimized bool, default FALSE gives interactive plot using leaflet, TRUE using image ggplot","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotMapWithTrips.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plots result of filtered trips on the map (from shape) — plotMapWithTrips","text":"plot trips filtered depending flags *.inshape map shapeTable","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotMapWithTripsType.html","id":null,"dir":"Reference","previous_headings":"","what":"Plots every type of trips(inside, outside, origin and destinating) on map — plotMapWithTripsType","title":"Plots every type of trips(inside, outside, origin and destinating) on map — plotMapWithTripsType","text":"Plots every type trips(inside, outside, origin destinating) map","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotMapWithTripsType.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plots every type of trips(inside, outside, origin and destinating) on map — plotMapWithTripsType","text":"","code":"plotMapWithTripsType(table, shapeTable, crs, optimized = FALSE)"},{"path":"https://vsp.berlin/matsim-r/reference/plotMapWithTripsType.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plots every type of trips(inside, outside, origin and destinating) on map — plotMapWithTripsType","text":"table tibble trips_output (readTripsTable()) shapeTable sf object(data.frame geometries), can received using st_read(path_to_geographical_file) crs numeric EPSG code proj4string, can found network file output directory MATSim simulation optimized bool, default FALSE gives interactive plot using leaflet, TRUE using image ggplot","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotMapWithTripsType.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plots every type of trips(inside, outside, origin and destinating) on map — plotMapWithTripsType","text":"plot contains every trip defined trip type","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotModalDistanceDistribution.html","id":null,"dir":"Reference","previous_headings":"","what":"Bar Chart with distance travelled on x-axis and number of trips on y-axis — plotModalDistanceDistribution","title":"Bar Chart with distance travelled on x-axis and number of trips on y-axis — plotModalDistanceDistribution","text":"Takes Table trips_output (readTripsTable()), plot bar chart values represent number trips ~ distance travelled Using parameters unite.columns, specific columns given, unite 1 mode name united.name(default 'united')","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotModalDistanceDistribution.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Bar Chart with distance travelled on x-axis and number of trips on y-axis — plotModalDistanceDistribution","text":"","code":"plotModalDistanceDistribution( tripsTable, unite.columns = character(0), united.name = \"united\", dump.output.to = matsimDumpOutputDirectory, only.files = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/plotModalDistanceDistribution.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Bar Chart with distance travelled on x-axis and number of trips on y-axis — plotModalDistanceDistribution","text":"tripsTable tible trips_output (readTripsTable()) unite.columns vector character strings, represent patterns columns united, changes name transport modes tibble copy united.name = \"united\" matches PATTERNS given unite.columns united.name character string, columns united, can specify name resulting column chart dump.output.folder saves configures yaml simwrapper dashboard. folder png plot stored .files boolean, represent plotting inside project needed, default FALSE - means function gives plot plot_ly","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotModalDistanceDistribution.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Bar Chart with distance travelled on x-axis and number of trips on y-axis — plotModalDistanceDistribution","text":"Bar Chart plot count trips among distance travelled","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotModalShiftBar.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot bar chart diagram of transport mode changes — plotModalShiftBar","title":"Plot bar chart diagram of transport mode changes — plotModalShiftBar","text":"Takes two trips_table (readTripsTable), collects changes transport mode distribution tables make bar chart diagram dodging positioning data","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotModalShiftBar.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot bar chart diagram of transport mode changes — plotModalShiftBar","text":"","code":"plotModalShiftBar( tripsTable1, tripsTable2, unite.columns = character(0), united.name = \"united\", dump.output.to = matsimDumpOutputDirectory, output.name = \"modalShiftBarChart\" )"},{"path":"https://vsp.berlin/matsim-r/reference/plotModalShiftBar.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot bar chart diagram of transport mode changes — plotModalShiftBar","text":"tripsTable1 tible trips_output (readTripsTable()) tripsTable2 tible trips_output (readTripsTable()) unite.columns vector character string, changes name transport modes tibble copy united.name = \"united\" matches PATTERNS given unite.columns united.name columns united, can specify name resulting column plot dump.output.folder saves configures yaml simwrapper. folder png plot stored","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotModalShiftBar.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot bar chart diagram of transport mode changes — plotModalShiftBar","text":"plots Bar Chart transport mode changes additional files simwrapper","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotModalShiftBar.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Plot bar chart diagram of transport mode changes — plotModalShiftBar","text":"Function calculates number transport mode used first second table, draws plot represent distribution transport mode changed (f. e. part concrete trasport mode changed another) Using parameter unite.columns transport modes match PATTERN unite.columns can united 1 transport mode type (default united.name \"united\") Using parameter show.onlyChanges","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotModalShiftSankey.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot alluvial/sankey diagram of transport mode changes — plotModalShiftSankey","title":"Plot alluvial/sankey diagram of transport mode changes — plotModalShiftSankey","text":"Takes two trips_table (readTripsTable), collects changes transport mode distribution tables make alluvial diagram data","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotModalShiftSankey.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot alluvial/sankey diagram of transport mode changes — plotModalShiftSankey","text":"","code":"plotModalShiftSankey( tripsTable1, tripsTable2, show.onlyChanges = FALSE, unite.columns = character(0), united.name = \"united\", dump.output.to = matsimDumpOutputDirectory )"},{"path":"https://vsp.berlin/matsim-r/reference/plotModalShiftSankey.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot alluvial/sankey diagram of transport mode changes — plotModalShiftSankey","text":"tripsTable1 tible trips_output (readTripsTable()) tripsTable2 tible trips_output (readTripsTable()) show.onlyChanges boolean, set TRUE => sankey diagram contains changes axes unite.columns vector character string, changes name transport modes tibble copy united.name = \"united\" matches PATTERNS given unite.columns united.name columns united, can specify name resulting column plot dump.output.folder saves configures yaml simwrapper. folder png plot stored","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotModalShiftSankey.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot alluvial/sankey diagram of transport mode changes — plotModalShiftSankey","text":"Alluvial diagram represents changes transport mode distribution trip tables","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotModalShiftSankey.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Plot alluvial/sankey diagram of transport mode changes — plotModalShiftSankey","text":"Function calculates number transport mode used first second table, draws plot represent distribution transport mode changed (f. e. part concrete trasport mode changed another) Using parameter unite.columns transport modes match PATTERN unite.columns can united 1 transport mode type (default united.name \"united\") Using parameter show.onlyChanges","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotModalSplitBarChart.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot main_mode distribution as a bar Chart — plotModalSplitBarChart","title":"Plot main_mode distribution as a bar Chart — plotModalSplitBarChart","text":"Takes Table trips_output (readTripsTable()), plot bar chart values represent percentage using transport modes trips","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotModalSplitBarChart.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot main_mode distribution as a bar Chart — plotModalSplitBarChart","text":"","code":"plotModalSplitBarChart( tripsTable, unite.columns = character(0), united.name = \"united\", dump.output.to = matsimDumpOutputDirectory, only.files = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/plotModalSplitBarChart.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot main_mode distribution as a bar Chart — plotModalSplitBarChart","text":"tripsTable tible trips_output (readTripsTable()) unite.columns vector character strings, represent patterns columns united, changes name transport modes tibble copy united.name = \"united\" matches PATTERNS given unite.columns united.name character string, columns united, can specify name resulting column chart dump.output.folder saves configures yaml simwrapper dashboard. folder png plot stored .files boolean, represent plotting inside project needed, default FALSE - means function gives plot plot_ly","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotModalSplitBarChart.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot main_mode distribution as a bar Chart — plotModalSplitBarChart","text":"Bar Chart plot transport mode distribution, values given percents","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotModalSplitBarChart.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Plot main_mode distribution as a bar Chart — plotModalSplitBarChart","text":"Function automatically detects transport_modes table plots pie chart percentage distribution. Using parameters unite.columns, specific columns given, unite 1 mode name united.name(default 'united')","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotModalSplitPieChart.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot main_mode distribution as a Pie Chart — plotModalSplitPieChart","title":"Plot main_mode distribution as a Pie Chart — plotModalSplitPieChart","text":"Takes Table trips_output (readTripsTable()), plot pie chart values represent percentage using transport modes trips","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotModalSplitPieChart.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot main_mode distribution as a Pie Chart — plotModalSplitPieChart","text":"","code":"plotModalSplitPieChart( tripsTable, unite.columns = character(0), united.name = \"united\", dump.output.to = matsimDumpOutputDirectory, only.files = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/plotModalSplitPieChart.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot main_mode distribution as a Pie Chart — plotModalSplitPieChart","text":"tripsTable tible trips_output (readTripsTable()) unite.columns vector character strings, represent patterns columns united, changes name transport modes tibble copy united.name = \"united\" matches PATTERNS given unite.columns united.name character string, columns united, can specify name resulting column chart dump.output.folder saves configures yaml simwrapper dashboard. folder png plot stored .files boolean, represent plotting inside project needed, default FALSE - means function gives plot plot_ly","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotModalSplitPieChart.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot main_mode distribution as a Pie Chart — plotModalSplitPieChart","text":"Pie Chart plot transport mode distribution, values given percents","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotModalSplitPieChart.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Plot main_mode distribution as a Pie Chart — plotModalSplitPieChart","text":"Function automatically detects transport_modes table plots pie chart. Using parameters unite.columns, specific columns given, unite 1 mode name united.name(default 'united')","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotStartActCountByDepTime.html","id":null,"dir":"Reference","previous_headings":"","what":"Scatter plot with departure time x-axis and number start activities on y-axis — plotStartActCountByDepTime","title":"Scatter plot with departure time x-axis and number start activities on y-axis — plotStartActCountByDepTime","text":"Takes Table trips_output (readTripsTable()), plot scatter plot values represent count start activities specific departure time main_mode Using parameters unite.columns, specific columns given, unite 1 mode name united.name(default 'united')","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotStartActCountByDepTime.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Scatter plot with departure time x-axis and number start activities on y-axis — plotStartActCountByDepTime","text":"","code":"plotStartActCountByDepTime( tripsTable, unite.columns = character(0), united.name = \"united\", dump.output.to = matsimDumpOutputDirectory, only.files = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/plotStartActCountByDepTime.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Scatter plot with departure time x-axis and number start activities on y-axis — plotStartActCountByDepTime","text":"tripsTable tible trips_output (readTripsTable()) unite.columns vector character strings, represent patterns columns united, changes name transport modes tibble copy united.name = \"united\" matches PATTERNS given unite.columns united.name character string, columns united, can specify name resulting column chart dump.output.folder saves configures yaml simwrapper dashboard. folder png plot stored .files boolean, represent plotting inside project needed, default FALSE - means function gives plot plot_ly","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotStartActCountByDepTime.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Scatter plot with departure time x-axis and number start activities on y-axis — plotStartActCountByDepTime","text":"Bar Chart plot distance traveled per mode","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotTripCountByDepTime.html","id":null,"dir":"Reference","previous_headings":"","what":"Line plot with departure time x-axis and number of trips on y-axis — plotTripCountByDepTime","title":"Line plot with departure time x-axis and number of trips on y-axis — plotTripCountByDepTime","text":"Takes Table trips_output (readTripsTable()), make line plot values represent count trips specific departure time main_mode Using parameters unite.columns, specific columns given, unite 1 mode name united.name(default 'united')","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotTripCountByDepTime.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Line plot with departure time x-axis and number of trips on y-axis — plotTripCountByDepTime","text":"","code":"plotTripCountByDepTime( tripsTable, unite.columns = character(0), united.name = \"united\", dump.output.to = matsimDumpOutputDirectory, only.files = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/plotTripCountByDepTime.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Line plot with departure time x-axis and number of trips on y-axis — plotTripCountByDepTime","text":"tripsTable tible trips_output (readTripsTable()) unite.columns vector character strings, represent patterns columns united, changes name transport modes tibble copy united.name = \"united\" matches PATTERNS given unite.columns united.name character string, columns united, can specify name resulting column chart dump.output.folder saves configures yaml simwrapper dashboard. folder png plot stored .files boolean, represent plotting inside project needed, default FALSE - means function gives plot plot_ly","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotTripCountByDepTime.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Line plot with departure time x-axis and number of trips on y-axis — plotTripCountByDepTime","text":"Line Chart plot trips count departure mode per mode","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotTripDistanceByMode.html","id":null,"dir":"Reference","previous_headings":"","what":"Bar Chart with distance travelled on x-axis and number of trips on y-axis — plotTripDistanceByMode","title":"Bar Chart with distance travelled on x-axis and number of trips on y-axis — plotTripDistanceByMode","text":"Takes Table trips_output (readTripsTable()), plot bar chart values represent average distance traveled ~ main mode used Using parameters unite.columns, specific columns given, unite 1 mode name united.name(default 'united')","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotTripDistanceByMode.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Bar Chart with distance travelled on x-axis and number of trips on y-axis — plotTripDistanceByMode","text":"","code":"plotTripDistanceByMode( tripsTable, unite.columns = character(0), united.name = \"united\", dump.output.to = matsimDumpOutputDirectory, only.files = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/plotTripDistanceByMode.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Bar Chart with distance travelled on x-axis and number of trips on y-axis — plotTripDistanceByMode","text":"tripsTable tible trips_output (readTripsTable()) unite.columns vector character strings, represent patterns columns united, changes name transport modes tibble copy united.name = \"united\" matches PATTERNS given unite.columns united.name character string, columns united, can specify name resulting column chart dump.output.folder saves configures yaml simwrapper dashboard. folder png plot stored .files boolean, represent plotting inside project needed, default FALSE - means function gives plot plot_ly","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotTripDistanceByMode.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Bar Chart with distance travelled on x-axis and number of trips on y-axis — plotTripDistanceByMode","text":"Bar Chart plot distance traveled per mode","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotTripDistancedByType.html","id":null,"dir":"Reference","previous_headings":"","what":"Bar Chart with tripType on x-axis and travelled distance on y-axis — plotTripDistancedByType","title":"Bar Chart with tripType on x-axis and travelled distance on y-axis — plotTripDistancedByType","text":"Takes Table trips_output (readTripsTable()), plot bar chart values represent travelled distance tripType related shapeTable","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotTripDistancedByType.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Bar Chart with tripType on x-axis and travelled distance on y-axis — plotTripDistancedByType","text":"","code":"plotTripDistancedByType( tripsTable, shapeTable, crs, dump.output.to = matsimDumpOutputDirectory )"},{"path":"https://vsp.berlin/matsim-r/reference/plotTripDistancedByType.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Bar Chart with tripType on x-axis and travelled distance on y-axis — plotTripDistancedByType","text":"tripsTable tible trips_output (readTripsTable()) shapeTable sf object(data.frame geometries), can received using st_read(path_to_geographical_file) crs numeric EPSG code proj4string, can found network file output directory MATSim simulation dump.output.folder saves configures yaml simwrapper dashboard. folder png plot stored","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotTripDistancedByType.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Bar Chart with tripType on x-axis and travelled distance on y-axis — plotTripDistancedByType","text":"Bar Chart plot distance traveled type","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotTripTypesPieChart.html","id":null,"dir":"Reference","previous_headings":"","what":"Plots distribution of every type of trips(inside, outside, origin and destinating) in Pie Chart — plotTripTypesPieChart","title":"Plots distribution of every type of trips(inside, outside, origin and destinating) in Pie Chart — plotTripTypesPieChart","text":"Plots distribution every type trips(inside, outside, origin destinating) Pie Chart","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotTripTypesPieChart.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plots distribution of every type of trips(inside, outside, origin and destinating) in Pie Chart — plotTripTypesPieChart","text":"","code":"plotTripTypesPieChart(table, shapeTable, crs)"},{"path":"https://vsp.berlin/matsim-r/reference/plotTripTypesPieChart.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plots distribution of every type of trips(inside, outside, origin and destinating) in Pie Chart — plotTripTypesPieChart","text":"table tibble trips_output (readTripsTable()) shapeTable sf object(data.frame geometries), can received using st_read(path_to_geographical_file) crs numeric EPSG code proj4string, can found network file output directory MATSim simulation","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotTripTypesPieChart.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plots distribution of every type of trips(inside, outside, origin and destinating) in Pie Chart — plotTripTypesPieChart","text":"plot percentage type trips","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotTripsByDistance.html","id":null,"dir":"Reference","previous_headings":"","what":"Bar Chart with distance travelled on x-axis and number of trips on y-axis — plotTripsByDistance","title":"Bar Chart with distance travelled on x-axis and number of trips on y-axis — plotTripsByDistance","text":"Takes Table trips_output (readTripsTable()), plot bar chart values represent number trips ~ distance travelled Using parameters unite.columns, specific columns given, unite 1 mode name united.name(default 'united')","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotTripsByDistance.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Bar Chart with distance travelled on x-axis and number of trips on y-axis — plotTripsByDistance","text":"","code":"plotTripsByDistance( tripsTable, unite.columns = character(0), united.name = \"united\", dump.output.to = matsimDumpOutputDirectory, only.files = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/plotTripsByDistance.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Bar Chart with distance travelled on x-axis and number of trips on y-axis — plotTripsByDistance","text":"tripsTable tible trips_output (readTripsTable()) unite.columns vector character strings, represent patterns columns united, changes name transport modes tibble copy united.name = \"united\" matches PATTERNS given unite.columns united.name character string, columns united, can specify name resulting column chart dump.output.folder saves configures yaml simwrapper dashboard. folder png plot stored .files boolean, represent plotting inside project needed, default FALSE - means function gives plot plot_ly","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plotTripsByDistance.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Bar Chart with distance travelled on x-axis and number of trips on y-axis — plotTripsByDistance","text":"Bar Chart plot count trips among distance travelled","code":""},{"path":"https://vsp.berlin/matsim-r/reference/prepareComparisonSimwrapperDashboardFromTable.html","id":null,"dir":"Reference","previous_headings":"","what":"Creates comparison dashboard for the 2 given tables or folder with data — prepareComparisonSimwrapperDashboardFromTable","title":"Creates comparison dashboard for the 2 given tables or folder with data — prepareComparisonSimwrapperDashboardFromTable","text":"Creates comparison dashboard 2 given tables folder data","code":""},{"path":"https://vsp.berlin/matsim-r/reference/prepareComparisonSimwrapperDashboardFromTable.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Creates comparison dashboard for the 2 given tables or folder with data — prepareComparisonSimwrapperDashboardFromTable","text":"","code":"prepareComparisonSimwrapperDashboardFromTable( table1, table2, dump.output.to = matsimDumpOutputDirectory, append = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/prepareComparisonSimwrapperDashboardFromTable.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Creates comparison dashboard for the 2 given tables or folder with data — prepareComparisonSimwrapperDashboardFromTable","text":"table1 trips_output tibble readTripsTable() table2 trips_output tibble readTripsTable() dump.output.folder saves configures yaml simwrapper dashboard plots using functions: plotModalSplitBarChart(),plotModalSplitPieChart(),plotModalShift(). append specifies ouput folder erased creating","code":""},{"path":"https://vsp.berlin/matsim-r/reference/prepareComparisonSimwrapperDashboardFromTable.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Creates comparison dashboard for the 2 given tables or folder with data — prepareComparisonSimwrapperDashboardFromTable","text":"generates folder content simwrapper trips table","code":""},{"path":"https://vsp.berlin/matsim-r/reference/prepareSimwrapperDashboardFromFolder.html","id":null,"dir":"Reference","previous_headings":"","what":"Creates dashboard for the given table or folder with data — prepareSimwrapperDashboardFromFolder","title":"Creates dashboard for the given table or folder with data — prepareSimwrapperDashboardFromFolder","text":"Creates dashboard given table folder data","code":""},{"path":"https://vsp.berlin/matsim-r/reference/prepareSimwrapperDashboardFromFolder.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Creates dashboard for the given table or folder with data — prepareSimwrapperDashboardFromFolder","text":"","code":"prepareSimwrapperDashboardFromFolder( folder, dump.output.to = matsimDumpOutputDirectory, append = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/prepareSimwrapperDashboardFromFolder.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Creates dashboard for the given table or folder with data — prepareSimwrapperDashboardFromFolder","text":"folder specifies data source folder tripsOutput dump.output.folder saves configures yaml simwrapper dashboard plots append specifies ouput folder erased creating","code":""},{"path":"https://vsp.berlin/matsim-r/reference/prepareSimwrapperDashboardFromFolder.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Creates dashboard for the given table or folder with data — prepareSimwrapperDashboardFromFolder","text":"tibble output_trips folder. Generates content needed Simwrapper","code":""},{"path":"https://vsp.berlin/matsim-r/reference/prepareSimwrapperDashboardFromTable.html","id":null,"dir":"Reference","previous_headings":"","what":"Creates dashboard for the given table or folder with data — prepareSimwrapperDashboardFromTable","title":"Creates dashboard for the given table or folder with data — prepareSimwrapperDashboardFromTable","text":"Creates dashboard given table folder data","code":""},{"path":"https://vsp.berlin/matsim-r/reference/prepareSimwrapperDashboardFromTable.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Creates dashboard for the given table or folder with data — prepareSimwrapperDashboardFromTable","text":"","code":"prepareSimwrapperDashboardFromTable( table, dump.output.to = matsimDumpOutputDirectory, append = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/prepareSimwrapperDashboardFromTable.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Creates dashboard for the given table or folder with data — prepareSimwrapperDashboardFromTable","text":"table trips_output tibble readTripsTable() dump.output.folder saves configures yaml simwrapper dashboard plots using functions: plotModalSplitBarChart(),plotModalSplitPieChart(),plotModalShift(). append specifies ouput folder erased creating","code":""},{"path":"https://vsp.berlin/matsim-r/reference/prepareSimwrapperDashboardFromTable.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Creates dashboard for the given table or folder with data — prepareSimwrapperDashboardFromTable","text":"generates folder content simwrapper trips table","code":""},{"path":"https://vsp.berlin/matsim-r/reference/processDtvEstimationQuality.html","id":null,"dir":"Reference","previous_headings":"","what":"Categorize DTV deviation and aggregate data — processDtvEstimationQuality","title":"Categorize DTV deviation and aggregate data — processDtvEstimationQuality","text":"Takes tibble mergeCountsAndLinks. Deviation count volumes Linkstats calculated (e.g. deviation 1.2 means 20 percent DTV MATSim counts) categorized. parameter 'aggr' set TRUE, data aggregated run link type. Can used visualize model quality link type compare several runs.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/processDtvEstimationQuality.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Categorize DTV deviation and aggregate data — processDtvEstimationQuality","text":"","code":"processDtvEstimationQuality( joinedFrame, aggr = TRUE, ll = ~x * 0.8 - 200, ul = ~x * 1.2 + 200 )"},{"path":"https://vsp.berlin/matsim-r/reference/processDtvEstimationQuality.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Categorize DTV deviation and aggregate data — processDtvEstimationQuality","text":"joinedFrame tibble mergeCountsAndLinks aggr Boolean, categorized data returned aggregated ll Formula calculate lower limit quality label 'exact', default = 0.8*x - 200 ul Formula calculate lower limit quality label 'exact', default = 1.2*x + 200","code":""},{"path":"https://vsp.berlin/matsim-r/reference/processDtvEstimationQuality.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Categorize DTV deviation and aggregate data — processDtvEstimationQuality","text":"long-format tibble, contains share estimation quality scenario link type, aggr FALSE disaggregated data returned","code":""},{"path":"https://vsp.berlin/matsim-r/reference/processDtvEstimationQuality.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Categorize DTV deviation and aggregate data — processDtvEstimationQuality","text":"Estimation quality determinated 'cut' function, limits label 'exact' can adjusted tuning parameter 'll' 'ul'","code":""},{"path":"https://vsp.berlin/matsim-r/reference/processLinkStatsDtvDistribution.html","id":null,"dir":"Reference","previous_headings":"","what":"Categorize DTV and calculate DTV distribution — processLinkStatsDtvDistribution","title":"Categorize DTV and calculate DTV distribution — processLinkStatsDtvDistribution","text":"Takes tibble mergeCountsAndLinks. DTV categorized bins. Finally data aggregated calculate DTV distribution link type category, excluding 'residential' 'unclassified' Data can used create multiple geom_col plots visualize compare DTV distributions count data several MATSim runs","code":""},{"path":"https://vsp.berlin/matsim-r/reference/processLinkStatsDtvDistribution.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Categorize DTV and calculate DTV distribution — processLinkStatsDtvDistribution","text":"","code":"processLinkStatsDtvDistribution(joinedFrame, from = 0, to = 40000, by = 5000)"},{"path":"https://vsp.berlin/matsim-r/reference/processLinkStatsDtvDistribution.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Categorize DTV and calculate DTV distribution — processLinkStatsDtvDistribution","text":"joinedFrame tibble mergeCountsAndLinks Lower limit count bin Upper limit count bins Size count bin","code":""},{"path":"https://vsp.berlin/matsim-r/reference/processLinkStatsDtvDistribution.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Categorize DTV and calculate DTV distribution — processLinkStatsDtvDistribution","text":"long-format tibble contains share DTV Categories","code":""},{"path":"https://vsp.berlin/matsim-r/reference/readCounts.html","id":null,"dir":"Reference","previous_headings":"","what":"Load a MATSim Counts file into memory — readCounts","title":"Load a MATSim Counts file into memory — readCounts","text":"Loads MATSim Counts XML-File tibble memory","code":""},{"path":"https://vsp.berlin/matsim-r/reference/readCounts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Load a MATSim Counts file into memory — readCounts","text":"","code":"readCounts(file)"},{"path":"https://vsp.berlin/matsim-r/reference/readCounts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Load a MATSim Counts file into memory — readCounts","text":"file File load. Must .xml file","code":""},{"path":"https://vsp.berlin/matsim-r/reference/readCounts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Load a MATSim Counts file into memory — readCounts","text":"tibble containing MATSim Link id \"loc_id\" key","code":""},{"path":"https://vsp.berlin/matsim-r/reference/readLinkStats.html","id":null,"dir":"Reference","previous_headings":"","what":"Load linkstats as tibble into memory — readLinkStats","title":"Load linkstats as tibble into memory — readLinkStats","text":"Reads Linkstats .tsv created LinkStats.class dataframe memory. Counts can provided time bins. Counts can provided qsim mode. argument networkModes used select filter columns.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/readLinkStats.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Load linkstats as tibble into memory — readLinkStats","text":"","code":"readLinkStats(runId, file, sampleSize = 0.25)"},{"path":"https://vsp.berlin/matsim-r/reference/readLinkStats.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Load linkstats as tibble into memory — readLinkStats","text":"runId Id tag columns DTV file File load. Must .csv .tsv file comma separator sampleSize sample size MATSim scenario scale DTV values","code":""},{"path":"https://vsp.berlin/matsim-r/reference/readLinkStats.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Load linkstats as tibble into memory — readLinkStats","text":"Tibble link stats qsim mode","code":""},{"path":"https://vsp.berlin/matsim-r/reference/readPersonsTable.html","id":null,"dir":"Reference","previous_headings":"","what":"Load MATSim output_persons table into memory — readPersonsTable","title":"Load MATSim output_persons table into memory — readPersonsTable","text":"Loads MATSim CSV output_persons file archive, creating tibble columns csv file copied + adopted code readTripsTable tripsOutput.R","code":""},{"path":"https://vsp.berlin/matsim-r/reference/readPersonsTable.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Load MATSim output_persons table into memory — readPersonsTable","text":"","code":"readPersonsTable(input_path = \".\")"},{"path":"https://vsp.berlin/matsim-r/reference/readPersonsTable.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Load MATSim output_persons table into memory — readPersonsTable","text":"input_path character string, path local MATSim output directory, persons csv directly, http link file.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/readPersonsTable.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Load MATSim output_persons table into memory — readPersonsTable","text":"tibble output_persons","code":""},{"path":"https://vsp.berlin/matsim-r/reference/readTripsTable.html","id":null,"dir":"Reference","previous_headings":"","what":"Load MATSIM output_trips table into Memory — readTripsTable","title":"Load MATSIM output_trips table into Memory — readTripsTable","text":"Loads MATSim CSV output_trips file archive, creating tibble columns csv file","code":""},{"path":"https://vsp.berlin/matsim-r/reference/readTripsTable.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Load MATSIM output_trips table into Memory — readTripsTable","text":"","code":"readTripsTable(input_path = \".\")"},{"path":"https://vsp.berlin/matsim-r/reference/readTripsTable.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Load MATSIM output_trips table into Memory — readTripsTable","text":"input_path character string, path matsim output directory http link file.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/readTripsTable.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Load MATSIM output_trips table into Memory — readTripsTable","text":"tibble trips_output","code":""},{"path":"https://vsp.berlin/matsim-r/reference/symlog_trans.html","id":null,"dir":"Reference","previous_headings":"","what":"A function to create symlog scaling for a plot — symlog_trans","title":"A function to create symlog scaling for a plot — symlog_trans","text":"Can used symlog scale axis ggplot object. called createCountScatterPlot. Note function taken Stackoverflow! informations, see thread : https://stackoverflow.com/questions/14613355/--get-something-like-matplotlibs-symlog-scale--ggplot--lattice","code":""},{"path":"https://vsp.berlin/matsim-r/reference/symlog_trans.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"A function to create symlog scaling for a plot — symlog_trans","text":"","code":"symlog_trans(base = 10, thr = 1, scale = 1)"},{"path":"https://vsp.berlin/matsim-r/reference/symlog_trans.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"A function to create symlog scaling for a plot — symlog_trans","text":"base base log thr threshold data scaled log","code":""},{"path":"https://vsp.berlin/matsim-r/reference/transformToSf.html","id":null,"dir":"Reference","previous_headings":"","what":"Transforms trips_table tibble (from readTripsTable) from tibble to sf (table with attribute features and geometry feature) — transformToSf","title":"Transforms trips_table tibble (from readTripsTable) from tibble to sf (table with attribute features and geometry feature) — transformToSf","text":"Takes trips_table (readTripsTable) transforms trips_table sf object using start_x, end_x, start_y, end_y geometry features deletes resulting data.frame start_x, end_x, start_y, end_y. adds wkt column, geometry.type = st_mulitpoint(), geometry.type = st_linestring() adds start_wkt end_wkt, geometry.type = st_point() Added column/columns projected given CRS (coordinate reference system), can taken network file MATSimOutputDirectory","code":""},{"path":"https://vsp.berlin/matsim-r/reference/transformToSf.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Transforms trips_table tibble (from readTripsTable) from tibble to sf (table with attribute features and geometry feature) — transformToSf","text":"","code":"transformToSf(table, crs, geometry.type = st_multipoint())"},{"path":"https://vsp.berlin/matsim-r/reference/transformToSf.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Transforms trips_table tibble (from readTripsTable) from tibble to sf (table with attribute features and geometry feature) — transformToSf","text":"table tibble trips_output (readTripsTable()) crs numeric EPSG code proj4string, can found network file output directory MATSim simulation geometry.type function sf transformation, geometry.type can (default st_multipoint()) !!!st_point()-resulting table contains 2 geometries start_wkt end_wkt, representing start end POINTs, type POINT!!! !!!st_multipoint()-resulting table contains 1 geometry wkt, representing start end POINTS MULTIPOINT!!! !!!st_linestring() - resulting table contains 1 geometry wkt, representing line start end points LINESTRING!!!","code":""},{"path":"https://vsp.berlin/matsim-r/reference/transformToSf.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Transforms trips_table tibble (from readTripsTable) from tibble to sf (table with attribute features and geometry feature) — transformToSf","text":"sf object (data.frame geometries depending geometry.type)","code":""},{"path":"https://vsp.berlin/matsim-r/reference/transformToSf.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Transforms trips_table tibble (from readTripsTable) from tibble to sf (table with attribute features and geometry feature) — transformToSf","text":"Function also sets attribute geometry.type resulting table character value \"POINT\",\"MULTIPOINT\",\"LINESTRING\" get type table generated, needed","code":""}] +[{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":null,"dir":"","previous_headings":"","what":"GNU General Public License","title":"GNU General Public License","text":"Version 3, 29 June 2007Copyright © 2007 Free Software Foundation, Inc.  Everyone permitted copy distribute verbatim copies license document, changing allowed.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"preamble","dir":"","previous_headings":"","what":"Preamble","title":"GNU General Public License","text":"GNU General Public License free, copyleft license software kinds works. licenses software practical works designed take away freedom share change works. contrast, GNU General Public License intended guarantee freedom share change versions program–make sure remains free software users. , Free Software Foundation, use GNU General Public License software; applies also work released way authors. can apply programs, . speak free software, referring freedom, price. General Public Licenses designed make sure freedom distribute copies free software (charge wish), receive source code can get want , can change software use pieces new free programs, know can things. protect rights, need prevent others denying rights asking surrender rights. Therefore, certain responsibilities distribute copies software, modify : responsibilities respect freedom others. example, distribute copies program, whether gratis fee, must pass recipients freedoms received. must make sure , , receive can get source code. must show terms know rights. Developers use GNU GPL protect rights two steps: (1) assert copyright software, (2) offer License giving legal permission copy, distribute /modify . developers’ authors’ protection, GPL clearly explains warranty free software. users’ authors’ sake, GPL requires modified versions marked changed, problems attributed erroneously authors previous versions. devices designed deny users access install run modified versions software inside , although manufacturer can . fundamentally incompatible aim protecting users’ freedom change software. systematic pattern abuse occurs area products individuals use, precisely unacceptable. Therefore, designed version GPL prohibit practice products. problems arise substantially domains, stand ready extend provision domains future versions GPL, needed protect freedom users. Finally, every program threatened constantly software patents. States allow patents restrict development use software general-purpose computers, , wish avoid special danger patents applied free program make effectively proprietary. prevent , GPL assures patents used render program non-free. precise terms conditions copying, distribution modification follow.","code":""},{"path":[]},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_0-definitions","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"0. Definitions","title":"GNU General Public License","text":"“License” refers version 3 GNU General Public License. “Copyright” also means copyright-like laws apply kinds works, semiconductor masks. “Program” refers copyrightable work licensed License. licensee addressed “”. “Licensees” “recipients” may individuals organizations. “modify” work means copy adapt part work fashion requiring copyright permission, making exact copy. resulting work called “modified version” earlier work work “based ” earlier work. “covered work” means either unmodified Program work based Program. “propagate” work means anything , without permission, make directly secondarily liable infringement applicable copyright law, except executing computer modifying private copy. Propagation includes copying, distribution (without modification), making available public, countries activities well. “convey” work means kind propagation enables parties make receive copies. Mere interaction user computer network, transfer copy, conveying. interactive user interface displays “Appropriate Legal Notices” extent includes convenient prominently visible feature (1) displays appropriate copyright notice, (2) tells user warranty work (except extent warranties provided), licensees may convey work License, view copy License. interface presents list user commands options, menu, prominent item list meets criterion.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_1-source-code","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"1. Source Code","title":"GNU General Public License","text":"“source code” work means preferred form work making modifications . “Object code” means non-source form work. “Standard Interface” means interface either official standard defined recognized standards body, , case interfaces specified particular programming language, one widely used among developers working language. “System Libraries” executable work include anything, work whole, () included normal form packaging Major Component, part Major Component, (b) serves enable use work Major Component, implement Standard Interface implementation available public source code form. “Major Component”, context, means major essential component (kernel, window system, ) specific operating system () executable work runs, compiler used produce work, object code interpreter used run . “Corresponding Source” work object code form means source code needed generate, install, (executable work) run object code modify work, including scripts control activities. However, include work’s System Libraries, general-purpose tools generally available free programs used unmodified performing activities part work. example, Corresponding Source includes interface definition files associated source files work, source code shared libraries dynamically linked subprograms work specifically designed require, intimate data communication control flow subprograms parts work. Corresponding Source need include anything users can regenerate automatically parts Corresponding Source. Corresponding Source work source code form work.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_2-basic-permissions","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"2. Basic Permissions","title":"GNU General Public License","text":"rights granted License granted term copyright Program, irrevocable provided stated conditions met. License explicitly affirms unlimited permission run unmodified Program. output running covered work covered License output, given content, constitutes covered work. License acknowledges rights fair use equivalent, provided copyright law. may make, run propagate covered works convey, without conditions long license otherwise remains force. may convey covered works others sole purpose make modifications exclusively , provide facilities running works, provided comply terms License conveying material control copyright. thus making running covered works must exclusively behalf, direction control, terms prohibit making copies copyrighted material outside relationship . Conveying circumstances permitted solely conditions stated . Sublicensing allowed; section 10 makes unnecessary.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_3-protecting-users-legal-rights-from-anti-circumvention-law","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"3. Protecting Users’ Legal Rights From Anti-Circumvention Law","title":"GNU General Public License","text":"covered work shall deemed part effective technological measure applicable law fulfilling obligations article 11 WIPO copyright treaty adopted 20 December 1996, similar laws prohibiting restricting circumvention measures. convey covered work, waive legal power forbid circumvention technological measures extent circumvention effected exercising rights License respect covered work, disclaim intention limit operation modification work means enforcing, work’s users, third parties’ legal rights forbid circumvention technological measures.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_4-conveying-verbatim-copies","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"4. Conveying Verbatim Copies","title":"GNU General Public License","text":"may convey verbatim copies Program’s source code receive , medium, provided conspicuously appropriately publish copy appropriate copyright notice; keep intact notices stating License non-permissive terms added accord section 7 apply code; keep intact notices absence warranty; give recipients copy License along Program. may charge price price copy convey, may offer support warranty protection fee.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_5-conveying-modified-source-versions","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"5. Conveying Modified Source Versions","title":"GNU General Public License","text":"may convey work based Program, modifications produce Program, form source code terms section 4, provided also meet conditions: ) work must carry prominent notices stating modified , giving relevant date. b) work must carry prominent notices stating released License conditions added section 7. requirement modifies requirement section 4 “keep intact notices”. c) must license entire work, whole, License anyone comes possession copy. License therefore apply, along applicable section 7 additional terms, whole work, parts, regardless packaged. License gives permission license work way, invalidate permission separately received . d) work interactive user interfaces, must display Appropriate Legal Notices; however, Program interactive interfaces display Appropriate Legal Notices, work need make . compilation covered work separate independent works, nature extensions covered work, combined form larger program, volume storage distribution medium, called “aggregate” compilation resulting copyright used limit access legal rights compilation’s users beyond individual works permit. Inclusion covered work aggregate cause License apply parts aggregate.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_6-conveying-non-source-forms","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"6. Conveying Non-Source Forms","title":"GNU General Public License","text":"may convey covered work object code form terms sections 4 5, provided also convey machine-readable Corresponding Source terms License, one ways: ) Convey object code , embodied , physical product (including physical distribution medium), accompanied Corresponding Source fixed durable physical medium customarily used software interchange. b) Convey object code , embodied , physical product (including physical distribution medium), accompanied written offer, valid least three years valid long offer spare parts customer support product model, give anyone possesses object code either (1) copy Corresponding Source software product covered License, durable physical medium customarily used software interchange, price reasonable cost physically performing conveying source, (2) access copy Corresponding Source network server charge. c) Convey individual copies object code copy written offer provide Corresponding Source. alternative allowed occasionally noncommercially, received object code offer, accord subsection 6b. d) Convey object code offering access designated place (gratis charge), offer equivalent access Corresponding Source way place charge. need require recipients copy Corresponding Source along object code. place copy object code network server, Corresponding Source may different server (operated third party) supports equivalent copying facilities, provided maintain clear directions next object code saying find Corresponding Source. Regardless server hosts Corresponding Source, remain obligated ensure available long needed satisfy requirements. e) Convey object code using peer--peer transmission, provided inform peers object code Corresponding Source work offered general public charge subsection 6d. separable portion object code, whose source code excluded Corresponding Source System Library, need included conveying object code work. “User Product” either (1) “consumer product”, means tangible personal property normally used personal, family, household purposes, (2) anything designed sold incorporation dwelling. determining whether product consumer product, doubtful cases shall resolved favor coverage. particular product received particular user, “normally used” refers typical common use class product, regardless status particular user way particular user actually uses, expects expected use, product. product consumer product regardless whether product substantial commercial, industrial non-consumer uses, unless uses represent significant mode use product. “Installation Information” User Product means methods, procedures, authorization keys, information required install execute modified versions covered work User Product modified version Corresponding Source. information must suffice ensure continued functioning modified object code case prevented interfered solely modification made. convey object code work section , , specifically use , User Product, conveying occurs part transaction right possession use User Product transferred recipient perpetuity fixed term (regardless transaction characterized), Corresponding Source conveyed section must accompanied Installation Information. requirement apply neither third party retains ability install modified object code User Product (example, work installed ROM). requirement provide Installation Information include requirement continue provide support service, warranty, updates work modified installed recipient, User Product modified installed. Access network may denied modification materially adversely affects operation network violates rules protocols communication across network. Corresponding Source conveyed, Installation Information provided, accord section must format publicly documented (implementation available public source code form), must require special password key unpacking, reading copying.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_7-additional-terms","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"7. Additional Terms","title":"GNU General Public License","text":"“Additional permissions” terms supplement terms License making exceptions one conditions. Additional permissions applicable entire Program shall treated though included License, extent valid applicable law. additional permissions apply part Program, part may used separately permissions, entire Program remains governed License without regard additional permissions. convey copy covered work, may option remove additional permissions copy, part . (Additional permissions may written require removal certain cases modify work.) may place additional permissions material, added covered work, can give appropriate copyright permission. Notwithstanding provision License, material add covered work, may (authorized copyright holders material) supplement terms License terms: ) Disclaiming warranty limiting liability differently terms sections 15 16 License; b) Requiring preservation specified reasonable legal notices author attributions material Appropriate Legal Notices displayed works containing ; c) Prohibiting misrepresentation origin material, requiring modified versions material marked reasonable ways different original version; d) Limiting use publicity purposes names licensors authors material; e) Declining grant rights trademark law use trade names, trademarks, service marks; f) Requiring indemnification licensors authors material anyone conveys material (modified versions ) contractual assumptions liability recipient, liability contractual assumptions directly impose licensors authors. non-permissive additional terms considered “restrictions” within meaning section 10. Program received , part , contains notice stating governed License along term restriction, may remove term. license document contains restriction permits relicensing conveying License, may add covered work material governed terms license document, provided restriction survive relicensing conveying. add terms covered work accord section, must place, relevant source files, statement additional terms apply files, notice indicating find applicable terms. Additional terms, permissive non-permissive, may stated form separately written license, stated exceptions; requirements apply either way.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_8-termination","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"8. Termination","title":"GNU General Public License","text":"may propagate modify covered work except expressly provided License. attempt otherwise propagate modify void, automatically terminate rights License (including patent licenses granted third paragraph section 11). However, cease violation License, license particular copyright holder reinstated () provisionally, unless copyright holder explicitly finally terminates license, (b) permanently, copyright holder fails notify violation reasonable means prior 60 days cessation. Moreover, license particular copyright holder reinstated permanently copyright holder notifies violation reasonable means, first time received notice violation License (work) copyright holder, cure violation prior 30 days receipt notice. Termination rights section terminate licenses parties received copies rights License. rights terminated permanently reinstated, qualify receive new licenses material section 10.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_9-acceptance-not-required-for-having-copies","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"9. Acceptance Not Required for Having Copies","title":"GNU General Public License","text":"required accept License order receive run copy Program. Ancillary propagation covered work occurring solely consequence using peer--peer transmission receive copy likewise require acceptance. However, nothing License grants permission propagate modify covered work. actions infringe copyright accept License. Therefore, modifying propagating covered work, indicate acceptance License .","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_10-automatic-licensing-of-downstream-recipients","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"10. Automatic Licensing of Downstream Recipients","title":"GNU General Public License","text":"time convey covered work, recipient automatically receives license original licensors, run, modify propagate work, subject License. responsible enforcing compliance third parties License. “entity transaction” transaction transferring control organization, substantially assets one, subdividing organization, merging organizations. propagation covered work results entity transaction, party transaction receives copy work also receives whatever licenses work party’s predecessor interest give previous paragraph, plus right possession Corresponding Source work predecessor interest, predecessor can get reasonable efforts. may impose restrictions exercise rights granted affirmed License. example, may impose license fee, royalty, charge exercise rights granted License, may initiate litigation (including cross-claim counterclaim lawsuit) alleging patent claim infringed making, using, selling, offering sale, importing Program portion .","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_11-patents","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"11. Patents","title":"GNU General Public License","text":"“contributor” copyright holder authorizes use License Program work Program based. work thus licensed called contributor’s “contributor version”. contributor’s “essential patent claims” patent claims owned controlled contributor, whether already acquired hereafter acquired, infringed manner, permitted License, making, using, selling contributor version, include claims infringed consequence modification contributor version. purposes definition, “control” includes right grant patent sublicenses manner consistent requirements License. contributor grants non-exclusive, worldwide, royalty-free patent license contributor’s essential patent claims, make, use, sell, offer sale, import otherwise run, modify propagate contents contributor version. following three paragraphs, “patent license” express agreement commitment, however denominated, enforce patent (express permission practice patent covenant sue patent infringement). “grant” patent license party means make agreement commitment enforce patent party. convey covered work, knowingly relying patent license, Corresponding Source work available anyone copy, free charge terms License, publicly available network server readily accessible means, must either (1) cause Corresponding Source available, (2) arrange deprive benefit patent license particular work, (3) arrange, manner consistent requirements License, extend patent license downstream recipients. “Knowingly relying” means actual knowledge , patent license, conveying covered work country, recipient’s use covered work country, infringe one identifiable patents country reason believe valid. , pursuant connection single transaction arrangement, convey, propagate procuring conveyance , covered work, grant patent license parties receiving covered work authorizing use, propagate, modify convey specific copy covered work, patent license grant automatically extended recipients covered work works based . patent license “discriminatory” include within scope coverage, prohibits exercise , conditioned non-exercise one rights specifically granted License. may convey covered work party arrangement third party business distributing software, make payment third party based extent activity conveying work, third party grants, parties receive covered work , discriminatory patent license () connection copies covered work conveyed (copies made copies), (b) primarily connection specific products compilations contain covered work, unless entered arrangement, patent license granted, prior 28 March 2007. Nothing License shall construed excluding limiting implied license defenses infringement may otherwise available applicable patent law.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_12-no-surrender-of-others-freedom","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"12. No Surrender of Others’ Freedom","title":"GNU General Public License","text":"conditions imposed (whether court order, agreement otherwise) contradict conditions License, excuse conditions License. convey covered work satisfy simultaneously obligations License pertinent obligations, consequence may convey . example, agree terms obligate collect royalty conveying convey Program, way satisfy terms License refrain entirely conveying Program.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_13-use-with-the-gnu-affero-general-public-license","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"13. Use with the GNU Affero General Public License","title":"GNU General Public License","text":"Notwithstanding provision License, permission link combine covered work work licensed version 3 GNU Affero General Public License single combined work, convey resulting work. terms License continue apply part covered work, special requirements GNU Affero General Public License, section 13, concerning interaction network apply combination .","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_14-revised-versions-of-this-license","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"14. Revised Versions of this License","title":"GNU General Public License","text":"Free Software Foundation may publish revised /new versions GNU General Public License time time. new versions similar spirit present version, may differ detail address new problems concerns. version given distinguishing version number. Program specifies certain numbered version GNU General Public License “later version” applies , option following terms conditions either numbered version later version published Free Software Foundation. Program specify version number GNU General Public License, may choose version ever published Free Software Foundation. Program specifies proxy can decide future versions GNU General Public License can used, proxy’s public statement acceptance version permanently authorizes choose version Program. Later license versions may give additional different permissions. However, additional obligations imposed author copyright holder result choosing follow later version.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_15-disclaimer-of-warranty","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"15. Disclaimer of Warranty","title":"GNU General Public License","text":"WARRANTY PROGRAM, EXTENT PERMITTED APPLICABLE LAW. EXCEPT OTHERWISE STATED WRITING COPYRIGHT HOLDERS /PARTIES PROVIDE PROGRAM “” WITHOUT WARRANTY KIND, EITHER EXPRESSED IMPLIED, INCLUDING, LIMITED , IMPLIED WARRANTIES MERCHANTABILITY FITNESS PARTICULAR PURPOSE. ENTIRE RISK QUALITY PERFORMANCE PROGRAM . PROGRAM PROVE DEFECTIVE, ASSUME COST NECESSARY SERVICING, REPAIR CORRECTION.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_16-limitation-of-liability","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"16. Limitation of Liability","title":"GNU General Public License","text":"EVENT UNLESS REQUIRED APPLICABLE LAW AGREED WRITING COPYRIGHT HOLDER, PARTY MODIFIES /CONVEYS PROGRAM PERMITTED , LIABLE DAMAGES, INCLUDING GENERAL, SPECIAL, INCIDENTAL CONSEQUENTIAL DAMAGES ARISING USE INABILITY USE PROGRAM (INCLUDING LIMITED LOSS DATA DATA RENDERED INACCURATE LOSSES SUSTAINED THIRD PARTIES FAILURE PROGRAM OPERATE PROGRAMS), EVEN HOLDER PARTY ADVISED POSSIBILITY DAMAGES.","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"id_17-interpretation-of-sections-15-and-16","dir":"","previous_headings":"TERMS AND CONDITIONS","what":"17. Interpretation of Sections 15 and 16","title":"GNU General Public License","text":"disclaimer warranty limitation liability provided given local legal effect according terms, reviewing courts shall apply local law closely approximates absolute waiver civil liability connection Program, unless warranty assumption liability accompanies copy Program return fee. END TERMS CONDITIONS","code":""},{"path":"https://vsp.berlin/matsim-r/LICENSE.html","id":"how-to-apply-these-terms-to-your-new-programs","dir":"","previous_headings":"","what":"How to Apply These Terms to Your New Programs","title":"GNU General Public License","text":"develop new program, want greatest possible use public, best way achieve make free software everyone can redistribute change terms. , attach following notices program. safest attach start source file effectively state exclusion warranty; file least “copyright” line pointer full notice found. Also add information contact electronic paper mail. program terminal interaction, make output short notice like starts interactive mode: hypothetical commands show w show c show appropriate parts General Public License. course, program’s commands might different; GUI interface, use “box”. also get employer (work programmer) school, , sign “copyright disclaimer” program, necessary. information , apply follow GNU GPL, see . GNU General Public License permit incorporating program proprietary programs. program subroutine library, may consider useful permit linking proprietary applications library. want , use GNU Lesser General Public License instead License. first, please read .","code":" Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'. This is free software, and you are welcome to redistribute it under certain conditions; type 'show c' for details."},{"path":"https://vsp.berlin/matsim-r/articles/Exampleproject.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Example project","text":"vignette offers example workflow MATSim output thematic plots maps. general overview package structure please read introduction. short recap however: functions divided four categories start respective prefix. Read_, process_, plot_ compare_ future simwrapper_. better understand naming conventions (example create functions) consult vignette [LINK].","code":""},{"path":"https://vsp.berlin/matsim-r/articles/Exampleproject.html","id":"installation","dir":"Articles","previous_headings":"","what":"Installation","title":"Example project","text":"MATSim R yet available CRAN, install MATSim R using github, use following code.","code":"devtools::install_github(\"matsim-vsp/matsim-r\")"},{"path":"https://vsp.berlin/matsim-r/articles/Exampleproject.html","id":"loading-the-package","dir":"Articles","previous_headings":"","what":"Loading the package","title":"Example project","text":"installed, can load MATSim R package using library() function:","code":"library(matsim) library(sf)"},{"path":"https://vsp.berlin/matsim-r/articles/Exampleproject.html","id":"loading-data","dir":"Articles","previous_headings":"","what":"Loading data","title":"Example project","text":"data ’ll use example project result Leipzig run can find following link. (https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/leipzig/projects/namav/base-case/) want follow along, download copy folder. start, load output_trips.csv.gz file. zipped file, okay, functions can handle . also load shape file, can found . (https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/leipzig/leipzig-v1.1/input/shp/)","code":"trips_file_path <- \"paste_file_path_here\" # if you don't want to immediately load the whole file, the function read_output_trips has the option to only load the first n lines output_trips <- read_output_trips(trips_file_path, n_max = 5000)"},{"path":"https://vsp.berlin/matsim-r/articles/Exampleproject.html","id":"plot-a-modal-split","dir":"Articles","previous_headings":"","what":"Plot a modal split","title":"Example project","text":"two functions calculate plot modal splits: plot_mainmode_piechart() plot_mainmode_piechart(). name suggests first one plots modal split pie chart second one bar chart. , use processing function process_get_mainmode_distribution() plot resulting table. processing function can also used just get raw numbers. going plot bar chart: resulting bar chart looks like : Leipzig modal split","code":"plot_mainmode_barchart(output_trips)"},{"path":"https://vsp.berlin/matsim-r/articles/Exampleproject.html","id":"spatial-filter","dir":"Articles","previous_headings":"","what":"Spatial filter","title":"Example project","text":"next step want spatially filter data. far looking trips simulation, now want focus touch project area. can use function process_filter_by_shape() shape file ’ve already loaded. parameter crs coordinate system number spatial_type describes way trips interact project area. four options inside, outside, originating destinating. case look originating trips. Using plot_mainmode_barchart() 507 originating trips, results following chart: Leipzig modal split - trips originating project area","code":"trips_originating <- process_filter_by_shape(output_trips, leipzig_shp, crs = 25832, spatial_type = \"originating\" )"},{"path":"https://vsp.berlin/matsim-r/articles/Exampleproject.html","id":"comparison-plots","dir":"Articles","previous_headings":"","what":"Comparison plots","title":"Example project","text":"next step compare modal split base model modal split scenario. need load output_trips file scenario, e.g. one. https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/leipzig/projects/namav/drt-outskirts/ resulting plot looks like :","code":"#loading the scenario data output_trips_scenario <- read_output_trips(trips_file_scenario_path, n_max = 5000) #filtering the scenario data trips_scenario_originating <- process_filter_by_shape(output_trips_scenario, leipzig_shp, crs = 25832, spatial_type = \"originating\") #creating the comparison plot plot_compare_mainmode_barchart(trips_originating, trips_scenario_originating)"},{"path":"https://vsp.berlin/matsim-r/articles/Exampleproject.html","id":"maps","dir":"Articles","previous_headings":"","what":"Maps","title":"Example project","text":"package also allows plotting spatial data. example can plot trips originating project area see end. result interactive map using leaflet, showing places origin blue destinations red. (following image screenshot) Leipzig - originating trips","code":"plot_map_trips(trips_originating, crs = 25832)"},{"path":"https://vsp.berlin/matsim-r/articles/Introduction.html","id":"introduction","dir":"Articles","previous_headings":"","what":"Introduction","title":"Introduction to MATSim R Library: analyzing transport simulations","text":"Welcome MATSim R package! MATSim R R package designed data processing visualization provides wide range functions create adjustable plots processed data. vignette give overview structure package quickly guide process creating plots using functions provided library.","code":""},{"path":"https://vsp.berlin/matsim-r/articles/Introduction.html","id":"overall-concept","dir":"Articles","previous_headings":"","what":"Overall concept","title":"Introduction to MATSim R Library: analyzing transport simulations","text":"purpose package provide comprehensive set tools efficiently analyze output MATSim runs. package primarily processes output data stored CSV XML files, especially called “output_trips”, “legs” “persons” files. adhering standardized naming convention, package offers streamlined functionality reading, processing, plotting YAML file creation use Simwrapper. XXXX LINK SIMWRAPPER GITHUB xxxx Data flow concept matsim r package package organized four categories, serving specific purpose: Reading Functions: functions begin prefix “read_” designed read import simulation output. Field types automatically set tibble created. Processing Functions: Functions prefix “process_” form core package’s data manipulation capabilities. Users can apply variety transformations calculations loaded tibbles, allowing advanced processing analysis tailored specific needs. Spatial input/output also supported, enabling users manipulate analyze data spatial level well. Plotting Functions: plotting functions prefix “plot_” enable users create visualizations based processed output data. functions offer range plotting options, allowing users explore patterns, trends, relationships within simulation results. plotting functions encompass two additional subcategories, namely mapping comparing. Within mapping subcategory, users can generate visualizations overlay simulation results onto geographical maps, providing insights spatial patterns distributions. comparing subcategory offers tools compare different simulation outputs, allowing analysis understanding variations scenarios data sets. Simwrapper: simwrapper category specialized group within package facilitates plotting using YAML files Simwrapper. feature allows users define complex plots visualizations YAML format, providing convenient efficient way generate custom visual representations simulation data. structure MATSim R aims simplify analysis MATSim runs. provides users intuitive workflow, reading processing simulation output generating informative plots leveraging power YAML-based configurations.","code":""},{"path":"https://vsp.berlin/matsim-r/articles/Introduction.html","id":"installation","dir":"Articles","previous_headings":"","what":"Installation","title":"Introduction to MATSim R Library: analyzing transport simulations","text":"MATSim R yet available CRAN, install MATSim R using github, can use following code: However want use specific branch can specified like :","code":"devtools::install_github(\"matsim-vsp/matsim-r\") devtools::install_github(\"matsim-vsp/matsim-r\", ref = \"{name of the branch}\")"},{"path":"https://vsp.berlin/matsim-r/articles/Introduction.html","id":"loading-the-package","dir":"Articles","previous_headings":"","what":"Loading the package","title":"Introduction to MATSim R Library: analyzing transport simulations","text":"installed, can load MATSim R package using library() function:","code":"library(matsim)"},{"path":"https://vsp.berlin/matsim-r/articles/Introduction.html","id":"loading-data","dir":"Articles","previous_headings":"","what":"Loading Data","title":"Introduction to MATSim R Library: analyzing transport simulations","text":"first step analyzing transport simulations load output data R environment. MATSim provides several functions “read_” prefix purpose. Let’s take look can load simulation output stored CSV file: can now proceed explore analyze loaded data.","code":"# Specify the file path to your simulation output. # It can be a directory path or direct path to a file output_file <- \"path/to/your/output_trips.csv\" # Use the read_csv_trips() function to read the simulation data trips_data <- read_output_trips(output_file)"},{"path":"https://vsp.berlin/matsim-r/articles/Introduction.html","id":"data-processing","dir":"Articles","previous_headings":"","what":"Data Processing","title":"Introduction to MATSim R Library: analyzing transport simulations","text":"MATSim R offers range processing functions, prefixed “process_”, manipulate transform simulation data. functions allow perform various operations, filtering, aggregating, calculating additional metrics. Let’s see example applying transformation loaded data: XXXX EXAMPLE CORRECT? - filter shape?? XXXX Feel free explore different processing functions available package suit specific analysis requirements.","code":"# Filter the trips data to include only weekday trips weekday_trips <- process_filter_by_shape(trips_data) # Calculate the average trip duration average_duration <- process_get_travelwaittime_by_mainmode(weekday_trips)"},{"path":"https://vsp.berlin/matsim-r/articles/Introduction.html","id":"plotting","dir":"Articles","previous_headings":"","what":"Plotting","title":"Introduction to MATSim R Library: analyzing transport simulations","text":"Visualizing simulation data crucial gaining insights effectively communicating findings. MATSim R provides wide range plotting functions help create informative visualizations. Let’s create scatter plot visualize relationship trip distance trip duration: can customize plot appearance explore plot types, line plots, bar charts, spatial maps, using various plotting functions provided MATSim R.","code":"# Create a scatter plot of trip distance among different main modes plot_distance_by_mainmode_barchart(trips_data, x = \"distance\", y = \"duration\")"},{"path":"https://vsp.berlin/matsim-r/articles/Introduction.html","id":"advanced-features-still-in-development","dir":"Articles","previous_headings":"","what":"Advanced Features (still in development)","title":"Introduction to MATSim R Library: analyzing transport simulations","text":"still development -","code":""},{"path":"https://vsp.berlin/matsim-r/articles/Introduction.html","id":"conclusion","dir":"Articles","previous_headings":"","what":"Conclusion","title":"Introduction to MATSim R Library: analyzing transport simulations","text":"vignette, introduced MATSim R package, designed specifically analyzing MATSim outputs. hope ’ll great experience using library glad receive feedback https://github.com/matsim-vsp/matsim-r/tree/master mail soboliev@vsp.tu-berlin.de details specific usage examples, refer package documentation vignettes available. Happy analyzing MATSim R!","code":""},{"path":"https://vsp.berlin/matsim-r/articles/Namings.html","id":"overview","dir":"Articles","previous_headings":"","what":"Overview","title":"Namings","text":"function names built using naming template. Functions start specific verb (e.g. read, plot, process) describes main usage. sorted [function types] according usage. , following naming elements followed underscore. second element optional. specifies type action performed can used distinguish similar functions. following guide element called [clarification]. example element [compare], used functions compare two data sets. next element specifies data columns used. example column [mainmode] MATSim file [output_trips]. data going sorted filtered can necessary specify . done using []. example function [plot_arrtime_by_act]: plots column [arrtime], contains arrival time, [act] activity. Several can connected using []. last element can used specify output type. important plotting functions specifies type plot.","code":""},{"path":"https://vsp.berlin/matsim-r/articles/Namings.html","id":"template","dir":"Articles","previous_headings":"","what":"Template","title":"Namings","text":"summarize every naming template looks similar : [function_type]_{clarification}_[data]_{}_{category}_{}_…_{output_type} [function_type]: Describes type function, indicating primary purpose operation. example, “plot” plot functions, “process” data processing functions, “read” functions read data R environment. plot read process {clarification}: part optional provides additional details clarification function’s purpose behavior. helps distinguish similar functions variations function. example, “compare” indicate function performs comparison, “append” indicate function appends data, etc. plotting functions: compare map processing functions: get rename append filter convert [data]: Refers file column function handling manipulating. Examples include “arrtime” (arrival time), “distance” (distance traveled), “mainmode” (main transportation mode). Can read function str() {}: part optional indicates data filtered grouped specific category factor. serves connector [data] [category] components. {category}: Indicates specific category grouping factor used filter categorize data. Examples include “act” (activity), “spatialcat” (spatial category), “mainmode” (main transportation mode). {}: part optional used connector multiple categories involved function’s operation. {output_type}: Indicates type output result function generates. indicates format form data returned function. Examples include “barchart,” “piechart,” “linechart,” “table”.","code":""},{"path":"https://vsp.berlin/matsim-r/articles/Namings.html","id":"examples","dir":"Articles","previous_headings":"","what":"Examples","title":"Namings","text":"plot: Indicates function used plot data. arrtime: Refers “Arrival Time,” key aspect visualized. by_act: Indicates plot grouped “Activity.” plot: Indicates function used plot data. compare_count: Refers comparing count trips. by_spatialcat: Indicates comparison based “Spatial Categories.” barchart: Specifies type plot used visualization. plot: Indicates function used plot data. compare_distcat: Refers comparing distribution trips based “Distance Categories.” by_mainmode: Indicates comparison based different “Main Modes.” barchart: Specifies type plot used visualization. plot: Indicates function used plot data. compare_mainmode: Refers comparing different “Main Modes.” barchart: Specifies type plot used visualization. plot: Indicates function used plot data. compare_mainmode: Refers comparing different “Main Modes.” sankey: Specifies type plot used visualization, “Sankey Diagram.” plot: Indicates function used plot data. compare_travelwaittime: Refers comparing “Travel Time” “Wait Time.” by_mainmode: Indicates comparison based different “Main Modes.” plot: Indicates function used plot data. compare_travelwaittime: Refers comparing “Travel Time” “Wait Time.” by_mainmode: Indicates comparison based different “Main Modes.” barchart: Specifies type plot used visualization. plot: Indicates function used plot data. deptime: Refers “Departure Time,” key aspect visualized. by_act: Indicates plot segmented grouped “Activity.” plot: Indicates function used plot data. distance: Refers “Distance,” key aspect visualized. by_mainmode: Indicates plot segmented grouped different “Main Modes.” barchart: Specifies type plot used visualization. plot: Indicates function used plot data. distance: Refers “Distance,” key aspect visualized. by_spatialcat: Indicates plot segmented grouped “Spatial Categories.” barchart: Specifies type plot used visualization. plot: Indicates function used plot data. distcat: Refers “Distance Categories,” key aspect visualized. by_mainmode: Indicates plot segmented grouped different “Main Modes.” barchart: Specifies type plot used visualization. plot: Indicates function used plot data. mainmode: Refers “Main Modes,” key aspect visualized. barchart: Specifies type plot used visualization. plot: Indicates function used plot data. mainmode: Refers “Main Modes,” key aspect visualized. piechart: Specifies type plot used visualization. plot: Indicates function used plot data. map_trips: Refers “Mapping Trips,” key aspect visualized. process: Indicates function used process data. append_distcat: Refers appending “Distance Categories” trips_table. process: Indicates function used process data. append_spatialcat: Refers appending “Spatial Categories” trips_table. process: Indicates function used process data. convert_table_to_sf: Refers converting trips_table spatial data frame (sf). process: Indicates function used process data. convert_time: Refers converting time data trips_table specified format. process: Indicates function used process data. filter_by_shape: Refers filtering trips trips_table based shape.","code":""},{"path":"https://vsp.berlin/matsim-r/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Billy Charlton. Author, maintainer. Oleksandr Soboliev. Author.","code":""},{"path":"https://vsp.berlin/matsim-r/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Charlton B, Soboliev O (2023). matsim: R library interfacing MATSim agent-based microsimulation model. R package version 0.2.0, https://github.com/matsim-vsp/matsim-r.","code":"@Manual{, title = {matsim: R library for interfacing with MATSim agent-based microsimulation model}, author = {Billy Charlton and Oleksandr Soboliev}, year = {2023}, note = {R package version 0.2.0}, url = {https://github.com/matsim-vsp/matsim-r}, }"},{"path":"https://vsp.berlin/matsim-r/index.html","id":"matsim-r-support-package","dir":"","previous_headings":"","what":"R library for interfacing with MATSim agent-based microsimulation model","title":"R library for interfacing with MATSim agent-based microsimulation model","text":"MATSim https://matsim.org agent-based microsimulation package large-scape transport simulations. package mimics functionality Python matsim-tools package, eventually support standard MATSim networks, plans events. Currently network files supported, many summarization plots based MATSim standard output_trips file. One useful command builds SimWrapper dashboard standard MATSim output_trips.xml.gz file: R -e \"matsim::prepareSimwrapperDashboardFromFolder()\" work preliminary ongoing – submissions welcome!","code":""},{"path":"https://vsp.berlin/matsim-r/index.html","id":"install","dir":"","previous_headings":"","what":"Install","title":"R library for interfacing with MATSim agent-based microsimulation model","text":"can install package right now: install.packages(\"devtools\") devtools::install_github(\"matsim-vsp/matsim-r\") install package specific branch use: devtools::install_github(\"matsim-vsp/matsim-r\",ref=\"{name branch}\")","code":""},{"path":"https://vsp.berlin/matsim-r/index.html","id":"installing-from-gz-archive","dir":"","previous_headings":"Install","what":"Installing from .gz archive","title":"R library for interfacing with MATSim agent-based microsimulation model","text":"Instead using devtools can also install directly source archive: install.packages(\"matsim-r.tar.gz\", type=\"source\", repos=NULL)","code":""},{"path":"https://vsp.berlin/matsim-r/index.html","id":"documentation-build-instructions","dir":"","previous_headings":"","what":"Documentation build instructions","title":"R library for interfacing with MATSim agent-based microsimulation model","text":"Run GNU Make build docs whenever source files R/ change. create man pages well fancy HTML docs/ folder , build : devtools::document() builds docs NAMESPACE pkgdown::build_site() builds HTML docs","code":""},{"path":"https://vsp.berlin/matsim-r/reference/boxplotScoreDifferences.html","id":null,"dir":"Reference","previous_headings":"","what":"Boxplot of Score Differences — boxplotScoreDifferences","title":"Boxplot of Score Differences — boxplotScoreDifferences","text":"boxplotScoreDifferences function generates boxplot compare score differences two sets data represented personTibble_base personTibble_policy tibbles. provides insights distribution score differences two sets data.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/boxplotScoreDifferences.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Boxplot of Score Differences — boxplotScoreDifferences","text":"","code":"boxplotScoreDifferences(personTibble_base, personTibble_policy)"},{"path":"https://vsp.berlin/matsim-r/reference/boxplotScoreDifferences.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Boxplot of Score Differences — boxplotScoreDifferences","text":"personTibble_base persons tibble base case, can loaded readPersonsTable. personTibble_policy persons tibble policy case, can loaded readPersonsTable.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/boxplotScoreDifferences.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Boxplot of Score Differences — boxplotScoreDifferences","text":"ggplot boxplot distribution score differences","code":""},{"path":"https://vsp.berlin/matsim-r/reference/createCountScatterPlot.html","id":null,"dir":"Reference","previous_headings":"","what":"Creates a Via-Style scatterplot for each run — createCountScatterPlot","title":"Creates a Via-Style scatterplot for each run — createCountScatterPlot","text":"Takes tibble mergeCountsAndLinks. scatterplot counts x axis MATSim dtv y axis created colored road type. Lower upper limits define section considered 'exact' estimation. Limits defined custom formulas.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/createCountScatterPlot.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Creates a Via-Style scatterplot for each run — createCountScatterPlot","text":"","code":"createCountScatterPlot( joinedFrame, ll = ~x * 0.8 - 200, ul = ~x * 1.2 + 200, threshold = 100 )"},{"path":"https://vsp.berlin/matsim-r/reference/createCountScatterPlot.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Creates a Via-Style scatterplot for each run — createCountScatterPlot","text":"joinedFrame tibble mergeCountsAndLinks ll Formula calculate lower limit quality label 'exact', default = 0.8*x - 200 ul Formula calculate lower limit quality label 'exact', default = 1.2*x + 200 threshold Threshold data scaled log10.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/createCountScatterPlot.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Creates a Via-Style scatterplot for each run — createCountScatterPlot","text":"ggplot Scatterplotplot, can adjusted, needed.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/createCountScatterPlot.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Creates a Via-Style scatterplot for each run — createCountScatterPlot","text":"function calls matsim-r function processDtvEstimationQuality handling limits.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/generateXYHexagonYaml.html","id":null,"dir":"Reference","previous_headings":"","what":"Creates/adds XY hexagon definition of output trips to a summary dashboard — generateXYHexagonYaml","title":"Creates/adds XY hexagon definition of output trips to a summary dashboard — generateXYHexagonYaml","text":"Creates/adds XY hexagon definition output trips summary dashboard","code":""},{"path":"https://vsp.berlin/matsim-r/reference/generateXYHexagonYaml.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Creates/adds XY hexagon definition of output trips to a summary dashboard — generateXYHexagonYaml","text":"","code":"generateXYHexagonYaml( pathToOutputTrips, crs, dump.output.to = matsimDumpOutputDirectory )"},{"path":"https://vsp.berlin/matsim-r/reference/generateXYHexagonYaml.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Creates/adds XY hexagon definition of output trips to a summary dashboard — generateXYHexagonYaml","text":"pathToOutputTrips file path output_trips.csv file crs specifies coordinate reference system output_trips dump.output.path folder simwrapper dashboard","code":""},{"path":"https://vsp.berlin/matsim-r/reference/generateXYHexagonYaml.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Creates/adds XY hexagon definition of output trips to a summary dashboard — generateXYHexagonYaml","text":"changed file","code":""},{"path":"https://vsp.berlin/matsim-r/reference/matsimr-deprecated.html","id":null,"dir":"Reference","previous_headings":"","what":"Load MATSim network into memory — loadNetwork","title":"Load MATSim network into memory — loadNetwork","text":"loadNetwork - Loads MATSim XML network file, creating nodes tibble links tibble. node link attribute records network stored additional columns respective node link tibbles. links table automatically joined nodes table node x/y coordinates (node attributes) available links table without additional processing. readPersonsTable - Loads MATSim CSV output_persons file archive, creating tibble columns csv file copied + adopted code readTripsTable tripsOutput.R boxplotScoreDifferences - function generates boxplot compare score differences two sets data represented personTibble_base personTibble_policy tibbles. provides insights distribution score differences two sets data. functions provided compatibility older version matsimr package. may eventually completely removed.plotModalSplitPieChart - Takes Table trips_output (read_output_trips), plot pie chart values represent percentage using transport modes trips plotModalSplitBarChart - Takes Table trips_output (read_output_trips), plot bar chart values represent percentage using transport modes trips readTripsTable - Loads MATSim output_trips file file archive path, creating tibble plotAverageTravelWait - Takes Table trips_output (read_output_trips), plot bar chart values represent time spent traveling/waiting Using parameters unite.columns, specific columns given, unite 1 mode name united_name(default 'united') plotModalDistanceDistribution - Takes Table trips_output (read_output_trips), plot bar chart values represent number trips ~ distance travelled Using parameters unite.columns, specific columns given, unite 1 mode name united_name(default 'united') compareModalDistanceDistribution - Takes 2 Tables trips_output (read_output_trips), plot bar chart values represent difference number trips tripsTable2 tripsTable1 ~ distance travelled Using parameters unite.columns, specific columns given, unite 1 mode name united_name(default 'united') plotTripDistanceByMode - Takes Table trips_output (read_output_trips), plot bar chart values represent average distance traveled ~ main mode used Using parameters unite.columns, specific columns given, unite 1 mode name united_name(default 'united') plotTripCountByDepTime - Takes Table trips_output (read_output_trips), make line plot values represent count trips specific departure time main_mode Using parameters unite.columns, specific columns given, unite 1 mode name united_name(default 'united') plotActivityEndTimes - Takes Table trips_output (read_output_trips), make line plot values represent number activities ending specific time. Using parameters unite.columns, specific columns given, unite 1 mode name united_name(default 'united') plotArrivalTimesPerTripPurpose - Takes Table trips_output (read_output_trips), make line plot values represent count destination activities specific arrival time Using parameters unite.columns, specific columns given, unite 1 mode name united_name(default 'united') plotDepartureTimesPerTripPurpose - Takes Table trips_output (read_output_trips), make line plot values represent count destination activities specific arrival time Using parameters unite.columns, specific columns given, unite 1 mode name united_name(default 'united') plotTripDistancedByType - Takes Table trips_output (read_output_trips), plot bar chart values represent travelled distance tripType related shapeTable plotModalShiftSankey - Takes two trips_table (read_output_trips), collects changes transport mode distribution tables make alluvial diagram data Function calculates number transport mode used first second table, draws plot represent distribution transport mode changed (f. e. part concrete trasport mode changed another) Using parameter unite.columns transport modes match PATTERN unite.columns can united 1 transport mode type (default united_name \"united\") Using parameter show.onlyChanges plotModalShiftBar - Takes two trips_table (read_output_trips), collects changes transport mode distribution tables make bar chart diagram dodging positioning data Function calculates number transport mode used first second table, draws plot represent distribution transport mode changed (f. e. part concrete trasport mode changed another) Using parameter unite.columns transport modes match PATTERN unite.columns can united 1 transport mode type (default united_name \"united\") Using parameter show.onlyChanges plotMapWithFilteredTrips - Takes trips_table shapeTable(sf object file representing geographical data, can received using function st_read(path_to_file)) transforms objects match mutual CRS(network.xml MATSimOutputDirectory) filters trips table depending *.inshape flags: start.inshape = TRUE & end.inshape = TRUE return table contains trips inside given shape start.inshape = TRUE & end.inshape = FALSE return table contains trips starts shape ends shape start.inshape = FALSE & end.inshape = TRUE return table contains trips ends shape starts shape start.inshape = FALSE & end.inshape = FALSE return table contains trips starts ends given shape result filtering plotted map shapeTable green points startpoints trip red points endpoints trip plotMapWithTrips - Plots start end coordinates given trips table osm map plotTripTypesPieChart - plots distribution every type trips(inside, outside, origin destinating) Pie Chart compareTripTypesBarChart - Creates BarChart changing trip types(originating,transit etc) 2 tables saves output dump.output.plotMapWithTripsType - plots every type trips(inside, outside, origin destinating) map compareBasePolicyOutput - Chooses function compare output_trips folders. baseFolder contains base outputs, policyFolder contains policy outputs. compareBasePolicyShapeOutput - Chooses function compare output_trips folders. baseFolder contains base outputs, policyFolder contains policy outputs. appendDistanceCategory - adds trips output tibble additional column represent distance category filterByRegion - Filtering trips_table(read_output_trips) depending located given shape Takes trips_table shapeTable(sf object file representing geographical data, can received using function st_read(path_to_file). Please aware filterByRegion currently works, one geometry loaded.) transforms objects match mutual CRS(network.xml MATSimOutputDirectory) filters trips table depending *.inshape flags: start.inshape = TRUE & end.inshape = TRUE return table contains trips inside given shape start.inshape = TRUE & end.inshape = FALSE return table contains trips starts shape ends shape start.inshape = FALSE & end.inshape = TRUE return table contains trips ends shape starts shape start.inshape = FALSE & end.inshape = FALSE return table contains trips starts ends given shape deriveODMatrix - Creates instance ODMatrix(origin/destination) conventional form simwrapper getCrsFromConfig - Reads coordinate reference system MATSim output directory output_config.xml transformToSf - Transforms trips_table tibble (read_output_trips) tibble sf (table attribute features geometry feature) Takes trips_table (read_output_trips) transforms trips_table sf object using start_x, end_x, start_y, end_y geometry features deletes resulting data.frame start_x, end_x, start_y, end_y. adds wkt column, geometry.type = st_mulitpoint(), geometry.type = st_linestring() adds start_wkt end_wkt, geometry.type = st_point() Added column/columns projected given CRS (coordinate reference system), can taken network file MATSimOutputDirectory Function also sets attribute geometry.type resulting table character value \"POINT\",\"MULTIPOINT\",\"LINESTRING\" get type table generated, needed","code":""},{"path":"https://vsp.berlin/matsim-r/reference/matsimr-deprecated.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Load MATSim network into memory — loadNetwork","text":"","code":"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())"},{"path":"https://vsp.berlin/matsim-r/reference/matsimr-deprecated.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Load MATSim network into memory — loadNetwork","text":"filename File load. Can XML gzipped XML input_path character string, path MATSim output directory http link file. n_max integer, maximum number lines read within output_trips personTibble_base persons tibble base case, can loaded readPersonsTable. personTibble_policy persons tibble policy case, can loaded readPersonsTable. tripsTable table output trips(read_output_trips) path trips_output file unite.columns vector character string, changes name transport modes tibble copy united_name = \"united\" matches PATTERNS given unite.columns united.name columns united, can specify name resulting column plot dump.output.path folder save csv file ODMatrix .files boolean, represent plotting inside project needed, default FALSE - means function gives plot plot_ly tripsTable1 tibble trips_output (read_output_trips,f.e. base case) tripsTable2 tibble trips_output (read_output_trips,f.e. policy case) shapeTable sf object(data.frame geometries), can received using st_read(path_to_geographical_file) crs numeric EPSG code proj4string, can found network file output directory MATSim simulation show.onlyChanges boolean, set TRUE => sankey diagram contains changes axes table tibble trips_output (read_output_trips) start.inshape bool, defines trips conclude (see Description) end.inshape bool, defines trips conclude (see Description) optimized bool, default FALSE gives interactive plot using leaflet, TRUE using image ggplot baseFolder specifies data source folder multiple base output_trips policyFolder specifies data source folder multiple policy output_trips shapeFilePath specifies shapeFile used comparison shapePath full path shapefile (simwrapper TRUE, folder shapeFile contain also .dbf name) simwrapper create output simwrapper form set path shapefile colnames specific shapefile contains known columns, specified name columns OD. given get numeric values outer logical represent table contain outside flow shape, folder specifies path find config geometry.type function sf transformation, geometry.type can (default st_multipoint()) !!!st_point()-resulting table contains 2 geometries start_wkt end_wkt, representing start end POINTs, type POINT!!! !!!st_multipoint()-resulting table contains 1 geometry wkt, representing start end POINTS MULTIPOINT!!! !!!st_linestring() - resulting table contains 1 geometry wkt, representing line start end points LINESTRING!!!","code":""},{"path":"https://vsp.berlin/matsim-r/reference/matsimr-deprecated.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Load MATSim network into memory — loadNetwork","text":"loadNetwork - \"nodes\" \"links\" tibbles list object. readPersonsTable - tibble output_persons boxplotScoreDifferences - ggplot boxplot distribution score differences plotModalSplitPieChart - Pie Chart plot transport mode distribution, values given percents plotModalSplitBarChart - Bar Chart plot transport mode distribution, values given percents readTripsTable - tibble output_trips plotAverageTravelWait - Bar Chart plot average time spent travel/wait plotModalDistanceDistribution Bar Chart plot count trips among distance travelled compareModalDistanceDistribution - Bar Chart plot count trips among distance travelled plotTripDistanceByMode - Bar Chart plot distance traveled per mode plotTripCountByDepTime - Line Chart plot trips count departure mode per mode plotActivityEndTimes Line plot departure time x-axis number start activities y-axis plotArrivalTimesPerTripPurpose - Line plot arrival time x-axis number end activities y-axis plotDepartureTimesPerTripPurpose - Line plot arrival time x-axis number end activities y-axis plotTripDistancedByType - Bar Chart plot distance traveled type plotModalShiftSankey - Alluvial diagram represents changes transport mode distribution trip tables plotModalShiftBar - plots Bar Chart transport mode changes additional files simwrapper plotMapWithFilteredTrips - plot trips filtered depending flags *.inshape map shapeTable plotMapWithTrips - plot trips plotTripTypesPieChart - plot percentage type trips compareTripTypesBarChart - plot percentage type trips 2 tables plotMapWithTripsType - plot contains every trip defined trip type compareBasePolicyOutput - list tibbles, list base policy output_trips tibble compareBasePolicyShapeOutput - list tibbles, list base policy output_trips tibble tibble output_trips distance category column filterByRegion - tibble, filtered trips depending shapeTable special flags (see Description) deriveODMatrix - tibble origin/destination matrix getCrsFromConfig - code coordinate reference system transformToSf - sf object (data.frame geometries depending geometry.type)","code":""},{"path":"https://vsp.berlin/matsim-r/reference/matsimr-deprecated.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Load MATSim network into memory — loadNetwork","text":"plotModalSplitPieChart now synonym plot_mainmode_piechartplotModalSplitBarChart now synonym plot_mainmode_barchartplotAverageTravelWait now synonym plot_travelwaittime_mean_barchartplotModalDistanceDistribution now synonym plot_distcat_by_mainmode_barchartplotTripDistanceByMode now synonym plot_distance_by_mainmode_barchartplotTripCountByDepTime now synonym plot_trips_count_by_deptime_and_mainmode_linechartplotActivityEndTimes part package(contained false logic)plotArrivalTimesPerTripPurposenow synonym plot_arrtime_by_actplotDepartureTimesPerTripPurpose now synonym plot_deptime_by_actplotTripTypesPieChart now synonym plot_spatialtype_by_shape_piechartplotMapWithFilteredTripsnot part package, can filter drawing mapplotMapWithTripsnow synonym plot_map_tripsplotMapWithTripsType now synonym plot_map_trips_by_spatialcatplotTripDistancedByType now synonym plot_distance_by_spatialcat_barchartplotModalShiftBar now synonym plot_compare_mainmode_barchartplotModalShiftSankey now synonym plot_compare_mainmode_sankeycompareAverageTravelWait now synonym plot_compare_travelwaittime_by_mainmode_barchartcompareTripTypesBarChartnow synonym plot_compare_count_by_spatialcat_barchartcompareModalDistanceDistribution now synonym plot_compare_distcat_by_mainmode_barchartcompareBasePolicyOutput used new package version, prepared completely removed package like keep new package, write soboliev@campus.tu-berlin.decompareBasePolicyShapeOutput used new package version, prepared completely removed package like keep new package, write soboliev@campus.tu-berlin.deappendDistanceCategorynow synonym process_append_distcatfilterByRegion now synonym process_filter_by_shapederiveODMatrix now synonym process_get_od_matrixgetCrsFromConfignow synonym process_get_crs_from_configtransformToSf now synonym process_convert_table_to_sfreadTripsTablenow synonym read_output_tripsreadConfig now synonym read_config","code":""},{"path":"https://vsp.berlin/matsim-r/reference/mergeCountsAndLinks.html","id":null,"dir":"Reference","previous_headings":"","what":"Join counts and linkstats to the network, creating a tibble into memory — mergeCountsAndLinks","title":"Join counts and linkstats to the network, creating a tibble into memory — mergeCountsAndLinks","text":"Function join counts, linkstats network links. Data can aggregated filtered time mode.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/mergeCountsAndLinks.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Join counts and linkstats to the network, creating a tibble into memory — mergeCountsAndLinks","text":"","code":"mergeCountsAndLinks( counts, network, linkStats, networkModes = c(\"car\"), aggr_to = c(\"day\", \"hour\"), earliest = 0, latest = 86400 )"},{"path":"https://vsp.berlin/matsim-r/reference/mergeCountsAndLinks.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Join counts and linkstats to the network, creating a tibble into memory — mergeCountsAndLinks","text":"counts Tibble counts data network Tibble network nodes links linkStats List linkstats tibbles networkModes Vector network modes analyzed, default \"car\". aggr_to Determines data aggregated hourly bins daily traffic volume, can either \"day\" \"hour\" earliest Integer. Lower limit filter link stats time, default = 0. latest Integer. Upper limit filter link stats time, default = 86400 (midnight).","code":""},{"path":"https://vsp.berlin/matsim-r/reference/mergeCountsAndLinks.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Join counts and linkstats to the network, creating a tibble into memory — mergeCountsAndLinks","text":"Long-format tibble MATSim link id key (\"loc_id\"), traffic volumes MATSim runs link type","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_arrtime_by_act.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot Arrival Time by Activity — plot_arrtime_by_act","title":"Plot Arrival Time by Activity — plot_arrtime_by_act","text":"plot_arrtime_by_act - Takes Table trips_output (read_output_trips()), make line plot values represent count destination activities specific arrival time Using parameters unite.columns, specific columns given, unite 1 mode name united_name(default 'united')","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_arrtime_by_act.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot Arrival Time by Activity — plot_arrtime_by_act","text":"","code":"plot_arrtime_by_act( trips_table, unite_activities = character(0), united_name = \"united\" )"},{"path":"https://vsp.berlin/matsim-r/reference/plot_arrtime_by_act.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot Arrival Time by Activity — plot_arrtime_by_act","text":"trips_table tibble trips_output (read_output_trips) unite_activities vector character strings, represent patterns columns united, changes name activity types tibble copy united_name = \"united\" matches PATTERNS given unite.columns united_name character string, columns united, can specify name resulting column plot","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_arrtime_by_act.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot Arrival Time by Activity — plot_arrtime_by_act","text":"plotly object representing line plot arrival time activity.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_count_by_spatialcat_barchart.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot Comparison of Count by Spatial Category (Bar Chart) — plot_compare_count_by_spatialcat_barchart","title":"Plot Comparison of Count by Spatial Category (Bar Chart) — plot_compare_count_by_spatialcat_barchart","text":"plot_compare_count_by_spatialcat_barchart function generates bar chart compare count trips two trips_table tibbles across different spatial categories. provides insights distribution trips across spatial categories table.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_count_by_spatialcat_barchart.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot Comparison of Count by Spatial Category (Bar Chart) — plot_compare_count_by_spatialcat_barchart","text":"","code":"plot_compare_count_by_spatialcat_barchart( trips_table1, trips_table2, shape_table, crs )"},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_count_by_spatialcat_barchart.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot Comparison of Count by Spatial Category (Bar Chart) — plot_compare_count_by_spatialcat_barchart","text":"trips_table1 tible trips_output (read_output_trips) trips_table2 tible trips_output (read_output_trips) shape_table spatial shapefile spatial polygons data frame used create spatial categories. crs numeric representation EPSG code proj4string corresponding coordinate system trip coordinates, can found network file output directory MATSim simulation","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_count_by_spatialcat_barchart.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot Comparison of Count by Spatial Category (Bar Chart) — plot_compare_count_by_spatialcat_barchart","text":"plotly object representing bar chart comparison count spatial category.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_distcat_by_mainmode_barchart.html","id":null,"dir":"Reference","previous_headings":"","what":"Bar chart comparing distance traveled on x-axis and number of trips on y-axis for two different runs\nTakes two data frames (from read_output_trips), categorizes the traveled distances into pre-defined bins\nand plots the difference in number of trips for each bin. (Bins: 1000,2000,5000,10000,20000,50000,100000 (m))\nUsing the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') — plot_compare_distcat_by_mainmode_barchart","title":"Bar chart comparing distance traveled on x-axis and number of trips on y-axis for two different runs\nTakes two data frames (from read_output_trips), categorizes the traveled distances into pre-defined bins\nand plots the difference in number of trips for each bin. (Bins: 1000,2000,5000,10000,20000,50000,100000 (m))\nUsing the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') — plot_compare_distcat_by_mainmode_barchart","text":"Bar chart comparing distance traveled x-axis number trips y-axis two different runs Takes two data frames (read_output_trips), categorizes traveled distances pre-defined bins plots difference number trips bin. (Bins: 1000,2000,5000,10000,20000,50000,100000 (m)) Using parameter unite_modes, specific modes can renamed one name specified united_name (default 'united')","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_distcat_by_mainmode_barchart.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Bar chart comparing distance traveled on x-axis and number of trips on y-axis for two different runs\nTakes two data frames (from read_output_trips), categorizes the traveled distances into pre-defined bins\nand plots the difference in number of trips for each bin. (Bins: 1000,2000,5000,10000,20000,50000,100000 (m))\nUsing the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') — plot_compare_distcat_by_mainmode_barchart","text":"","code":"plot_compare_distcat_by_mainmode_barchart( trips_table1, trips_table2, unite_modes = character(0), united_name = \"united\", dist_column = \"dist_cat\", distances_array = c(1000, 2000, 5000, 10000, 20000, 50000, 1e+05) )"},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_distcat_by_mainmode_barchart.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Bar chart comparing distance traveled on x-axis and number of trips on y-axis for two different runs\nTakes two data frames (from read_output_trips), categorizes the traveled distances into pre-defined bins\nand plots the difference in number of trips for each bin. (Bins: 1000,2000,5000,10000,20000,50000,100000 (m))\nUsing the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') — plot_compare_distcat_by_mainmode_barchart","text":"trips_table1 tibble trips_output (read_output_trips), number trips table extracted number trips tripsTable1 trips_table2 tibble trips_output (read_output_trips), number trips table number trips tripsTable1 extracted unite_modes vector character strings, changes names chosen modes column main_mode new chosen name (.e. drtNorth drtSouth drt), using function (process_rename_mainmodes) united_name character string, specifies name united mode dist_column character string specifying column name trips_table tibble contains distance categories. distances_array numeric vector defining distance thresholds creating distance categories.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_distcat_by_mainmode_barchart.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Bar chart comparing distance traveled on x-axis and number of trips on y-axis for two different runs\nTakes two data frames (from read_output_trips), categorizes the traveled distances into pre-defined bins\nand plots the difference in number of trips for each bin. (Bins: 1000,2000,5000,10000,20000,50000,100000 (m))\nUsing the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') — plot_compare_distcat_by_mainmode_barchart","text":"Bar Chart plot count trips among distance travelled","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_mainmode_barchart.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot bar chart of changes in modal split — plot_compare_mainmode_barchart","title":"Plot bar chart of changes in modal split — plot_compare_mainmode_barchart","text":"Takes two data frames (read_output_trips), calculates changes mode shares plots bar chart Using parameter unite_modes, specific modes can renamed one name specified united_name (default 'united')","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_mainmode_barchart.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot bar chart of changes in modal split — plot_compare_mainmode_barchart","text":"","code":"plot_compare_mainmode_barchart( trips_table1, trips_table2, unite_modes = character(0), united_name = \"united\" )"},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_mainmode_barchart.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot bar chart of changes in modal split — plot_compare_mainmode_barchart","text":"trips_table1 tibble trips_output (read_output_trips) trips_table2 tibble trips_output (read_output_trips) unite_modes vector character strings, changes names chosen modes column main_mode new chosen name (.e. drtNorth drtSouth drt), using function (process_rename_mainmodes) united_name character string, specifies name united mode","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_mainmode_barchart.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot bar chart of changes in modal split — plot_compare_mainmode_barchart","text":"plots bar chart changes modal split","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_mainmode_sankey.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot alluvial/sankey diagram of transport mode changes — plot_compare_mainmode_sankey","title":"Plot alluvial/sankey diagram of transport mode changes — plot_compare_mainmode_sankey","text":"Takes two data frames (read_output_trips) compares mode choice agent summarizes results, showing modal shift. Using parameter unite_modes, specific modes can renamed one name specified united_name (default 'united') parameter show.onlyChanges allows visualization mode shift (excluding trips change mode). Standard value FALSE.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_mainmode_sankey.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot alluvial/sankey diagram of transport mode changes — plot_compare_mainmode_sankey","text":"","code":"plot_compare_mainmode_sankey( trips_table1, trips_table2, show_onlychanges = FALSE, unite_modes = character(0), united_name = \"united\" )"},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_mainmode_sankey.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot alluvial/sankey diagram of transport mode changes — plot_compare_mainmode_sankey","text":"trips_table1 tibble trips_output (read_output_trips()) trips_table2 tibble trips_output (read_output_trips()) show_onlychanges boolean, set TRUE sankey diagram shows mode shift unite_modes vector character strings, changes names chosen modes column main_mode new chosen name (.e. drtNorth drtSouth drt), using function (process_rename_mainmodes) united_name character string, specifies name united mode","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_mainmode_sankey.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot alluvial/sankey diagram of transport mode changes — plot_compare_mainmode_sankey","text":"Alluvial diagram represents changes transport mode distribution","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_score_boxplot.html","id":null,"dir":"Reference","previous_headings":"","what":"Boxplot of Score Differences — plot_compare_score_boxplot","title":"Boxplot of Score Differences — plot_compare_score_boxplot","text":"boxplotScoreDifferences function generates boxplot compare score differences two sets data represented personTibble_base personTibble_policy tibbles. provides insights distribution score differences two sets data.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_score_boxplot.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Boxplot of Score Differences — plot_compare_score_boxplot","text":"","code":"plot_compare_score_boxplot(personTibble_base, personTibble_policy)"},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_score_boxplot.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Boxplot of Score Differences — plot_compare_score_boxplot","text":"personTibble_base persons tibble base case, can loaded readPersonsTable. personTibble_policy persons tibble policy case, can loaded readPersonsTable.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_score_boxplot.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Boxplot of Score Differences — plot_compare_score_boxplot","text":"ggplot boxplot distribution score differences","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_travelwaittime_by_mainmode.html","id":null,"dir":"Reference","previous_headings":"","what":"Bar Chart comparing two runs with main_mode on x-axis and average travel/wait time on y-axis — plot_compare_travelwaittime_by_mainmode","title":"Bar Chart comparing two runs with main_mode on x-axis and average travel/wait time on y-axis — plot_compare_travelwaittime_by_mainmode","text":"Takes two data frames (read_output_trips), plot comparison bar chart travel wait times. Using parameter unite_modes, specific modes can renamed one name specified united_name (default 'united')","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_travelwaittime_by_mainmode.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Bar Chart comparing two runs with main_mode on x-axis and average travel/wait time on y-axis — plot_compare_travelwaittime_by_mainmode","text":"","code":"plot_compare_travelwaittime_by_mainmode( trips_table1, trips_table2, unite_modes = character(0), united_name = \"united\", time_format = \"minute\" )"},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_travelwaittime_by_mainmode.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Bar Chart comparing two runs with main_mode on x-axis and average travel/wait time on y-axis — plot_compare_travelwaittime_by_mainmode","text":"trips_table1 tibble trips_output (read_output_trips) trips_table2 tibble trips_output (read_output_trips) unite_modes vector character strings, changes names chosen modes column main_mode new chosen name (.e. drtNorth drtSouth drt), using function (process_rename_mainmodes) united_name character string, specifies name united mode#' time_format character string, defines time format used(takes \"hour\", \"minute\", \"second\")","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_travelwaittime_by_mainmode.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Bar Chart comparing two runs with main_mode on x-axis and average travel/wait time on y-axis — plot_compare_travelwaittime_by_mainmode","text":"Bar chart plot comparing average time spent travel/wait two runs","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_travelwaittime_by_mainmode_barchart.html","id":null,"dir":"Reference","previous_headings":"","what":"Comparison bar chart with main_mode on x-axis and average travel/wait time on y-axis — plot_compare_travelwaittime_by_mainmode_barchart","title":"Comparison bar chart with main_mode on x-axis and average travel/wait time on y-axis — plot_compare_travelwaittime_by_mainmode_barchart","text":"Takes data frame trips_output (read_output_trips), plot bar chart traveling/waiting time Using parameter unite_modes, specific modes can renamed one name specified united_name (default 'united')","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_travelwaittime_by_mainmode_barchart.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Comparison bar chart with main_mode on x-axis and average travel/wait time on y-axis — plot_compare_travelwaittime_by_mainmode_barchart","text":"","code":"plot_compare_travelwaittime_by_mainmode_barchart( trips_table1, trips_table2, unite_modes = character(0), united_name = \"united\", time_format = \"minute\" )"},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_travelwaittime_by_mainmode_barchart.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Comparison bar chart with main_mode on x-axis and average travel/wait time on y-axis — plot_compare_travelwaittime_by_mainmode_barchart","text":"trips_table1 tibble trips_output (read_output_trips) trips_table2 tibble trips_output (read_output_trips) unite_modes vector character strings, changes names chosen modes column main_mode new chosen name (.e. drtNorth drtSouth drt), using function (process_rename_mainmodes) united_name character string, specifies name united mode time_format character string, defines time format used(takes \"hour\", \"minute\", \"second\")","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_compare_travelwaittime_by_mainmode_barchart.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Comparison bar chart with main_mode on x-axis and average travel/wait time on y-axis — plot_compare_travelwaittime_by_mainmode_barchart","text":"Bar chart plot average travel/wait time","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_deptime_by_act.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot Departure Time by Activity — plot_deptime_by_act","title":"Plot Departure Time by Activity — plot_deptime_by_act","text":"plot_deptime_by_act function generates line plot visualize departure time trips activity given trips_table tibble. provides insights number trips starting different times activity.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_deptime_by_act.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot Departure Time by Activity — plot_deptime_by_act","text":"","code":"plot_deptime_by_act( trips_table, unite_activities = character(0), united_name = \"united\" )"},{"path":"https://vsp.berlin/matsim-r/reference/plot_deptime_by_act.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot Departure Time by Activity — plot_deptime_by_act","text":"unite_activities vector character strings, represent patterns columns united, changes name activity types tibble copy united_name = \"united\" matches PATTERNS given unite_columns united_name character string, columns united, can specify name resulting column plot tripsTable tibble trips_output (read_output_trips)","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_deptime_by_act.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot Departure Time by Activity — plot_deptime_by_act","text":"plotly object representing line plot departure time activity.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_distance_by_mainmode_barchart.html","id":null,"dir":"Reference","previous_headings":"","what":"Bar chart with average distance traveled for each mode on x-axis and number of trips on y-axis — plot_distance_by_mainmode_barchart","title":"Bar chart with average distance traveled for each mode on x-axis and number of trips on y-axis — plot_distance_by_mainmode_barchart","text":"Takes data frame trips_output (read_output_trips), plot bar chart average distance traveled main mode, Using parameter unite_modes, specific modes can renamed one name specified united_name (default 'united')","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_distance_by_mainmode_barchart.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Bar chart with average distance traveled for each mode on x-axis and number of trips on y-axis — plot_distance_by_mainmode_barchart","text":"","code":"plot_distance_by_mainmode_barchart( trips_table, unite_modes = character(0), united_name = \"united\", euclidean = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/plot_distance_by_mainmode_barchart.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Bar chart with average distance traveled for each mode on x-axis and number of trips on y-axis — plot_distance_by_mainmode_barchart","text":"trips_table tibble trips_output (read_output_trips) unite_modes vector character strings, changes names chosen modes column main_mode new chosen name (.e. drtNorth drtSouth drt), using function (process_rename_mainmodes) united_name character string, specifies name united mode euclidean Logical value indicating whether calculate average euclidean distance travel distance. Default FALSE, calculates average traveled distance.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_distance_by_mainmode_barchart.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Bar chart with average distance traveled for each mode on x-axis and number of trips on y-axis — plot_distance_by_mainmode_barchart","text":"Bar Chart plot distance traveled per mode","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_distance_by_spatialcat_barchart.html","id":null,"dir":"Reference","previous_headings":"","what":"Bar Chart with tripType on x-axis and travelled distance on y-axis — plot_distance_by_spatialcat_barchart","title":"Bar Chart with tripType on x-axis and travelled distance on y-axis — plot_distance_by_spatialcat_barchart","text":"Takes Table trips_output (read_output_trips), plot bar chart values represent travelled distance tripType related shapeTable","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_distance_by_spatialcat_barchart.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Bar Chart with tripType on x-axis and travelled distance on y-axis — plot_distance_by_spatialcat_barchart","text":"","code":"plot_distance_by_spatialcat_barchart( trips_table, shape_table, crs, euclidean = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/plot_distance_by_spatialcat_barchart.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Bar Chart with tripType on x-axis and travelled distance on y-axis — plot_distance_by_spatialcat_barchart","text":"trips_table tible trips_output (read_output_trips) crs numeric EPSG code proj4string, can found network file output directory MATSim simulation euclidean Logical value indicating whether calculate average euclidean distance travel distance. Default FALSE, calculates average traveled distance. shape_Table sf object(data frame geometries), can created using st_read(), used categorize trips.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_distance_by_spatialcat_barchart.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Bar Chart with tripType on x-axis and travelled distance on y-axis — plot_distance_by_spatialcat_barchart","text":"Bar Chart plot distance traveled spatial type","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_distcat_by_mainmode_barchart.html","id":null,"dir":"Reference","previous_headings":"","what":"Bar Chart with distance traveled on x-axis and number of trips on y-axis — plot_distcat_by_mainmode_barchart","title":"Bar Chart with distance traveled on x-axis and number of trips on y-axis — plot_distcat_by_mainmode_barchart","text":"Takes data frame trips_output (read_output_trips) categorizes traveled distances pre-defined bins plot histogram traveled distances. (Bins: 1000,2000,5000,10000,20000,50000,100000 (m)) Using parameter unite_modes, specific modes can renamed one name specified united_name (default 'united')","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_distcat_by_mainmode_barchart.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Bar Chart with distance traveled on x-axis and number of trips on y-axis — plot_distcat_by_mainmode_barchart","text":"","code":"plot_distcat_by_mainmode_barchart( trips_table, unite_modes = character(0), united_name = \"united\", dist_column = \"dist_cat\", distances_array = c(1000, 2000, 5000, 10000, 20000, 50000, 1e+05) )"},{"path":"https://vsp.berlin/matsim-r/reference/plot_distcat_by_mainmode_barchart.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Bar Chart with distance traveled on x-axis and number of trips on y-axis — plot_distcat_by_mainmode_barchart","text":"trips_table tibble trips_output (read_output_trips) unite_modes vector character strings, changes names chosen modes column main_mode new chosen name (.e. drtNorth drtSouth drt), using function (process_rename_mainmodes) united_name character string, specifies name united mode dist_column character string specifying column name trips_table tibble contains distance categories. distances_array numeric vector defining distance thresholds creating distance categories.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_distcat_by_mainmode_barchart.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Bar Chart with distance traveled on x-axis and number of trips on y-axis — plot_distcat_by_mainmode_barchart","text":"Plotly bar Chart count trips among distance travelled","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_mainmode_barchart.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot the distribution of modes as a bar chart — plot_mainmode_barchart","title":"Plot the distribution of modes as a bar chart — plot_mainmode_barchart","text":"Takes data frame trips_output (read_output_trips) plot bar chart modal split using column main_mode.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_mainmode_barchart.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot the distribution of modes as a bar chart — plot_mainmode_barchart","text":"","code":"plot_mainmode_barchart( trips_table, unite_modes = character(0), united_name = \"united\", percentage = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/plot_mainmode_barchart.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot the distribution of modes as a bar chart — plot_mainmode_barchart","text":"trips_table tibble trips_output (read_output_trips) unite_modes vector character strings, changes names chosen modes column main_mode new chosen name (.e. drtNorth drtSouth drt), using function (process_rename_mainmodes) united_name character string, specifies name united mode percentage boolean, default FALSE, sets output given percentage","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_mainmode_barchart.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot the distribution of modes as a bar chart — plot_mainmode_barchart","text":"Bar Chart plot transport mode distribution, values given percents","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_mainmode_barchart.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Plot the distribution of modes as a bar chart — plot_mainmode_barchart","text":"modal shares given percentages. Using parameter unite_modes, specific modes can renamed one name specified united_name (default 'united')","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_mainmode_piechart.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot the distribution of modes as a pie chart — plot_mainmode_piechart","title":"Plot the distribution of modes as a pie chart — plot_mainmode_piechart","text":"Uses dataframe trips_output (read_output_trips), plot pie chart modal split using column main_mode","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_mainmode_piechart.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot the distribution of modes as a pie chart — plot_mainmode_piechart","text":"","code":"plot_mainmode_piechart( trips_table, unite_modes = character(0), united_name = \"united\" )"},{"path":"https://vsp.berlin/matsim-r/reference/plot_mainmode_piechart.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot the distribution of modes as a pie chart — plot_mainmode_piechart","text":"trips_table tibble trips_output (read_output_trips) unite_modes vector character strings, changes names chosen modes column main_mode new chosen name (.e. drtNorth drtSouth drt), using function (process_rename_mainmodes) united_name character string, specifies name united mode","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_mainmode_piechart.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot the distribution of modes as a pie chart — plot_mainmode_piechart","text":"pie chart plot transport mode distribution, values given percent","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_mainmode_piechart.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Plot the distribution of modes as a pie chart — plot_mainmode_piechart","text":"function automatically detects modes plots pie chart. Using parameter unite_modes, specific modes can renamed one name specified united_name (default 'united')","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_map_trips.html","id":null,"dir":"Reference","previous_headings":"","what":"Plots start and end coordinates of the given trips table on an osm map — plot_map_trips","title":"Plots start and end coordinates of the given trips table on an osm map — plot_map_trips","text":"Plots start end coordinates given trips table osm map","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_map_trips.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plots start and end coordinates of the given trips table on an osm map — plot_map_trips","text":"","code":"plot_map_trips(trips_table, crs, optimized = FALSE, shape_table = NULL)"},{"path":"https://vsp.berlin/matsim-r/reference/plot_map_trips.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plots start and end coordinates of the given trips table on an osm map — plot_map_trips","text":"trips_table tibble trips_output (read_output_trips) crs numeric representation EPSG code proj4string corresponding coordinate system trip coordinates, can found network file output directory MATSim simulation optimized bool, default FALSE gives interactive plot using leaflet, TRUE using image ggplot shape_table spatial shapefile spatial polygons data frame used background. default NULL.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_map_trips.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plots start and end coordinates of the given trips table on an osm map — plot_map_trips","text":"leaflet/ggplot plot trips start-, end- points","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_map_trips_by_spatialcat.html","id":null,"dir":"Reference","previous_headings":"","what":"Plots every type of trips(inside, outside, origin and destinating) on map — plot_map_trips_by_spatialcat","title":"Plots every type of trips(inside, outside, origin and destinating) on map — plot_map_trips_by_spatialcat","text":"Plots every type trips(inside, outside, origin destinating) map","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_map_trips_by_spatialcat.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plots every type of trips(inside, outside, origin and destinating) on map — plot_map_trips_by_spatialcat","text":"","code":"plot_map_trips_by_spatialcat(trips_table, shape_table, crs, optimized = FALSE)"},{"path":"https://vsp.berlin/matsim-r/reference/plot_map_trips_by_spatialcat.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plots every type of trips(inside, outside, origin and destinating) on map — plot_map_trips_by_spatialcat","text":"trips_table tibble trips_output (read_output_trips) shape_table sf object(data.frame geometries), can received using st_read(path_to_geographical_file) crs numeric representation EPSG code proj4string corresponding coordinate system trip coordinates, can found network file output directory MATSim simulation optimized bool, default FALSE gives interactive plot using leaflet, TRUE creates image ggplot table tibble output_trips (read_output_trips()) shape_Table sf object(data frame geometries), can created using st_read(), used categorize trips.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_map_trips_by_spatialcat.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plots every type of trips(inside, outside, origin and destinating) on map — plot_map_trips_by_spatialcat","text":"plot contains every trip defined trip type","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_spatialtype_by_shape_piechart.html","id":null,"dir":"Reference","previous_headings":"","what":"Plots distribution of every type of trip(inside, outside, origin and destinating) as a pie chart — plot_spatialtype_by_shape_piechart","title":"Plots distribution of every type of trip(inside, outside, origin and destinating) as a pie chart — plot_spatialtype_by_shape_piechart","text":"Plots distribution every type trip(inside, outside, origin destinating) pie chart","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_spatialtype_by_shape_piechart.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plots distribution of every type of trip(inside, outside, origin and destinating) as a pie chart — plot_spatialtype_by_shape_piechart","text":"","code":"plot_spatialtype_by_shape_piechart(trips_table, shape_table, crs)"},{"path":"https://vsp.berlin/matsim-r/reference/plot_spatialtype_by_shape_piechart.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plots distribution of every type of trip(inside, outside, origin and destinating) as a pie chart — plot_spatialtype_by_shape_piechart","text":"trips_table tibble trips_output (read_output_trips) crs numeric representation EPSG code proj4string corresponding coordinate system trip coordinates, can found network file output directory MATSim simulation shape_Table sf object(data frame geometries), can created using st_read(), used categorize trips.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_spatialtype_by_shape_piechart.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plots distribution of every type of trip(inside, outside, origin and destinating) as a pie chart — plot_spatialtype_by_shape_piechart","text":"Pie chart showing percentage type trip","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_travelwaittime_mean_barchart.html","id":null,"dir":"Reference","previous_headings":"","what":"Plot travel and wait time for each mode as a bar chart — plot_travelwaittime_mean_barchart","title":"Plot travel and wait time for each mode as a bar chart — plot_travelwaittime_mean_barchart","text":"Takes data frame trips_output (read_output_trips), plot bar chart travel wait times. Using parameter unite_modes, specific modes can renamed one name specified united_name (default 'united')","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_travelwaittime_mean_barchart.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Plot travel and wait time for each mode as a bar chart — plot_travelwaittime_mean_barchart","text":"","code":"plot_travelwaittime_mean_barchart( trips_table, unite_modes = character(0), united_name = \"united\", time_format = \"minute\" )"},{"path":"https://vsp.berlin/matsim-r/reference/plot_travelwaittime_mean_barchart.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Plot travel and wait time for each mode as a bar chart — plot_travelwaittime_mean_barchart","text":"trips_table tibble trips_output (read_output_trips) unite_modes vector character strings, changes names chosen modes column main_mode new chosen name (.e. drtNorth drtSouth drt), using function (process_rename_mainmodes) united_name character string, specifies name united mode time_format character string indicating desired time format output. options \"minute\", \"hour\", \"second\". default \"minute\".","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_travelwaittime_mean_barchart.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Plot travel and wait time for each mode as a bar chart — plot_travelwaittime_mean_barchart","text":"Bar Chart plot average time spent travel/wait","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_trips_count_by_deptime_and_mainmode_linechart.html","id":null,"dir":"Reference","previous_headings":"","what":"Line plot with departure time on x-axis and number of trips on y-axis — plot_trips_count_by_deptime_and_mainmode_linechart","title":"Line plot with departure time on x-axis and number of trips on y-axis — plot_trips_count_by_deptime_and_mainmode_linechart","text":"Takes data frame trips_output (read_output_trips), create line plot number trips specific departure time main_mode Using parameter unite_modes, specific modes can renamed one name specified united_name (default 'united')","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_trips_count_by_deptime_and_mainmode_linechart.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Line plot with departure time on x-axis and number of trips on y-axis — plot_trips_count_by_deptime_and_mainmode_linechart","text":"","code":"plot_trips_count_by_deptime_and_mainmode_linechart( trips_table, unite_modes = character(0), united_name = \"united\" )"},{"path":"https://vsp.berlin/matsim-r/reference/plot_trips_count_by_deptime_and_mainmode_linechart.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Line plot with departure time on x-axis and number of trips on y-axis — plot_trips_count_by_deptime_and_mainmode_linechart","text":"trips_table tibble trips_output (read_output_trips) unite_modes vector character strings, changes names chosen modes column main_mode new chosen name (.e. drtNorth drtSouth drt), using function (process_rename_mainmodes) united_name character string, specifies name united mode","code":""},{"path":"https://vsp.berlin/matsim-r/reference/plot_trips_count_by_deptime_and_mainmode_linechart.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Line plot with departure time on x-axis and number of trips on y-axis — plot_trips_count_by_deptime_and_mainmode_linechart","text":"Line plot trips count departure time per mode","code":""},{"path":"https://vsp.berlin/matsim-r/reference/prepareComparisonSimwrapperDashboardFromTable.html","id":null,"dir":"Reference","previous_headings":"","what":"Creates comparison dashboard for the two given tables or folders with data — prepareComparisonSimwrapperDashboardFromTable","title":"Creates comparison dashboard for the two given tables or folders with data — prepareComparisonSimwrapperDashboardFromTable","text":"Creates comparison dashboard two given tables folders data","code":""},{"path":"https://vsp.berlin/matsim-r/reference/prepareComparisonSimwrapperDashboardFromTable.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Creates comparison dashboard for the two given tables or folders with data — prepareComparisonSimwrapperDashboardFromTable","text":"","code":"prepareComparisonSimwrapperDashboardFromTable( table1, table2, dump.output.to = matsimDumpOutputDirectory, append = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/prepareComparisonSimwrapperDashboardFromTable.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Creates comparison dashboard for the two given tables or folders with data — prepareComparisonSimwrapperDashboardFromTable","text":"table1 trips_output tibble readTripsTable() table2 trips_output tibble readTripsTable() dump.output.output folder, yaml files plots following functions saved : plotModalSplitBarChart(),plotModalSplitPieChart(),plotModalShift(). append specifies output folder erased creating, default = FALSE","code":""},{"path":"https://vsp.berlin/matsim-r/reference/prepareComparisonSimwrapperDashboardFromTable.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Creates comparison dashboard for the two given tables or folders with data — prepareComparisonSimwrapperDashboardFromTable","text":"generates folder content simwrapper trips table","code":""},{"path":"https://vsp.berlin/matsim-r/reference/prepareSimwrapperDashboardFromFolder.html","id":null,"dir":"Reference","previous_headings":"","what":"Creates dashboard for the given folder with data — prepareSimwrapperDashboardFromFolder","title":"Creates dashboard for the given folder with data — prepareSimwrapperDashboardFromFolder","text":"Creates dashboard given folder data","code":""},{"path":"https://vsp.berlin/matsim-r/reference/prepareSimwrapperDashboardFromFolder.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Creates dashboard for the given folder with data — prepareSimwrapperDashboardFromFolder","text":"","code":"prepareSimwrapperDashboardFromFolder( folder, dump.output.to = matsimDumpOutputDirectory, append = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/prepareSimwrapperDashboardFromFolder.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Creates dashboard for the given folder with data — prepareSimwrapperDashboardFromFolder","text":"folder file path, specifies data source folder includes output_trips.csv file dump.output.output folder, yaml files saved append specifies ouput folder erased creating, default = FALSE","code":""},{"path":"https://vsp.berlin/matsim-r/reference/prepareSimwrapperDashboardFromFolder.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Creates dashboard for the given folder with data — prepareSimwrapperDashboardFromFolder","text":"tibble output_trips folder content needed Simwrapper","code":""},{"path":"https://vsp.berlin/matsim-r/reference/prepareSimwrapperDashboardFromTable.html","id":null,"dir":"Reference","previous_headings":"","what":"Creates dashboard for the given table with data — prepareSimwrapperDashboardFromTable","title":"Creates dashboard for the given table with data — prepareSimwrapperDashboardFromTable","text":"Creates dashboard given table data","code":""},{"path":"https://vsp.berlin/matsim-r/reference/prepareSimwrapperDashboardFromTable.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Creates dashboard for the given table with data — prepareSimwrapperDashboardFromTable","text":"","code":"prepareSimwrapperDashboardFromTable( table, dump.output.to = matsimDumpOutputDirectory, append = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/prepareSimwrapperDashboardFromTable.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Creates dashboard for the given table with data — prepareSimwrapperDashboardFromTable","text":"table trips_output tibble readTripsTable() dump.output.output folder, yaml files plots following functions saved : plotModalSplitBarChart(),plotModalSplitPieChart(),plotModalShift(). append specifies ouput folder erased creating, default = FALSE","code":""},{"path":"https://vsp.berlin/matsim-r/reference/prepareSimwrapperDashboardFromTable.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Creates dashboard for the given table with data — prepareSimwrapperDashboardFromTable","text":"generates folder content simwrapper trips table","code":""},{"path":"https://vsp.berlin/matsim-r/reference/processDtvEstimationQuality.html","id":null,"dir":"Reference","previous_headings":"","what":"Categorize DTV deviation and aggregate data — processDtvEstimationQuality","title":"Categorize DTV deviation and aggregate data — processDtvEstimationQuality","text":"Takes tibble mergeCountsAndLinks. Deviation count volumes Linkstats calculated categorized (.e. deviation 1.2 means 20 percent DTV MATSim counts). parameter 'aggr' set TRUE, data aggregated run link type. Can used visualize model quality link type compare several runs.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/processDtvEstimationQuality.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Categorize DTV deviation and aggregate data — processDtvEstimationQuality","text":"","code":"processDtvEstimationQuality( joinedFrame, aggr = TRUE, ll = ~x * 0.8 - 200, ul = ~x * 1.2 + 200 )"},{"path":"https://vsp.berlin/matsim-r/reference/processDtvEstimationQuality.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Categorize DTV deviation and aggregate data — processDtvEstimationQuality","text":"joinedFrame tibble mergeCountsAndLinks aggr Boolean, categorized data returned aggregated, default TRUE. ll Formula calculate lower limit quality label 'exact', default = 0.8*x - 200 ul Formula calculate lower limit quality label 'exact', default = 1.2*x + 200","code":""},{"path":"https://vsp.berlin/matsim-r/reference/processDtvEstimationQuality.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Categorize DTV deviation and aggregate data — processDtvEstimationQuality","text":"long-format tibble, contains share estimation quality scenario link type, aggr FALSE disaggregated data returned","code":""},{"path":"https://vsp.berlin/matsim-r/reference/processDtvEstimationQuality.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Categorize DTV deviation and aggregate data — processDtvEstimationQuality","text":"Estimation quality determined 'cut' function, limits label 'exact' can adjusted tuning parameters 'll' (lower limit) 'ul' (upper limit)","code":""},{"path":"https://vsp.berlin/matsim-r/reference/processLinkStatsDtvDistribution.html","id":null,"dir":"Reference","previous_headings":"","what":"Categorize daily traffic volume (DTV) and calculate DTV for different link types. — processLinkStatsDtvDistribution","title":"Categorize daily traffic volume (DTV) and calculate DTV for different link types. — processLinkStatsDtvDistribution","text":"Takes tibble mergeCountsAndLinks. DTV categorized bins. Finally data aggregated calculate DTV distribution link type category, excluding 'residential' 'unclassified' Data can used create multiple geom_col plots visualize compare DTV distributions count data several MATSim runs","code":""},{"path":"https://vsp.berlin/matsim-r/reference/processLinkStatsDtvDistribution.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Categorize daily traffic volume (DTV) and calculate DTV for different link types. — processLinkStatsDtvDistribution","text":"","code":"processLinkStatsDtvDistribution(joinedFrame, from = 0, to = 40000, by = 5000)"},{"path":"https://vsp.berlin/matsim-r/reference/processLinkStatsDtvDistribution.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Categorize daily traffic volume (DTV) and calculate DTV for different link types. — processLinkStatsDtvDistribution","text":"joinedFrame tibble mergeCountsAndLinks Integer. Lower limit count bin, default = 0. Integer. Upper limit count bins, default = 40000. Integer. Size count bin, default = 5000.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/processLinkStatsDtvDistribution.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Categorize daily traffic volume (DTV) and calculate DTV for different link types. — processLinkStatsDtvDistribution","text":"long-format tibble contains share DTV link types","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_append_distcat.html","id":null,"dir":"Reference","previous_headings":"","what":"Adds additional dist_cat column based on the distances_array parameter — process_append_distcat","title":"Adds additional dist_cat column based on the distances_array parameter — process_append_distcat","text":"Categorizes trip distance bin based traveled distance. E.g. distance traveled 1500, distances array (1000,2000), category \"1000-2000\".","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_append_distcat.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Adds additional dist_cat column based on the distances_array parameter — process_append_distcat","text":"","code":"process_append_distcat( trips_table, distances_array = c(1000, 2000, 5000, 10000, 20000, 50000, 1e+05) )"},{"path":"https://vsp.berlin/matsim-r/reference/process_append_distcat.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Adds additional dist_cat column based on the distances_array parameter — process_append_distcat","text":"trips_table tibble output_trips (read_output_trips) distances_array numeric vector, represents segments distance categories ordered (meters), standard value: c(1000,2000,5000,10000,20000,50000,100000)","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_append_distcat.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Adds additional dist_cat column based on the distances_array parameter — process_append_distcat","text":"trips table added added column dist_cat","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_append_spatialcat.html","id":null,"dir":"Reference","previous_headings":"","what":"Appends an additional column with the trip type to output_trips — process_append_spatialcat","title":"Appends an additional column with the trip type to output_trips — process_append_spatialcat","text":"Using shape_file project area additional column created, categorizing trips following categories. inside: trips start end inside given shape originating: trips start inside shape end outside shape destinating: trips end inside shape start outside shape outside: trips start end outside shape","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_append_spatialcat.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Appends an additional column with the trip type to output_trips — process_append_spatialcat","text":"","code":"process_append_spatialcat(trips_table, shape_table, crs)"},{"path":"https://vsp.berlin/matsim-r/reference/process_append_spatialcat.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Appends an additional column with the trip type to output_trips — process_append_spatialcat","text":"trips_table tibble output_trips (read_output_trips()) crs numeric representation EPSG code proj4string corresponding coordinate system trip coordinates, can found network file output directory MATSim simulation shape_Table sf object(data frame geometries), can created using st_read(), used categorize trips.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_append_spatialcat.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Appends an additional column with the trip type to output_trips — process_append_spatialcat","text":"tibble, additional column containing trip type","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_append_spatialcat.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Appends an additional column with the trip type to output_trips — process_append_spatialcat","text":"Please aware process_filter_by_shape currently works, one geometry loaded.)","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_convert_table_to_sf.html","id":null,"dir":"Reference","previous_headings":"","what":"Transforms the data frame trips_output (from read_output_trips) from tibble to sf (table with geometry features) — process_convert_table_to_sf","title":"Transforms the data frame trips_output (from read_output_trips) from tibble to sf (table with geometry features) — process_convert_table_to_sf","text":"Transforms data frame trips_output (read_output_trips) sf object using start_x, end_x, start_y, end_y geometry features. geometry.type = st_multipoint() geometry.type = st_linestring() adds one geometry column (wkt format), geometry.type = st_point() adds geometry columns start_wkt end_wkt. Added column/columns projected given CRS (coordinate reference system). columns start_x, end_x, start_y, end_y deleted resulting data frame.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_convert_table_to_sf.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Transforms the data frame trips_output (from read_output_trips) from tibble to sf (table with geometry features) — process_convert_table_to_sf","text":"","code":"process_convert_table_to_sf(table, crs, geometry.type = st_multipoint())"},{"path":"https://vsp.berlin/matsim-r/reference/process_convert_table_to_sf.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Transforms the data frame trips_output (from read_output_trips) from tibble to sf (table with geometry features) — process_convert_table_to_sf","text":"table tibble trips_output (read_output_trips) crs numeric, coordinate system form EPSG code proj4string, can found MATSim network file geometry.type type sf transformation, default st_multipoint(), geometry.type can : !!!st_point()- resulting table contains two geometry columns: start_wkt end_wkt, representing start end points POINTS!!! !!!st_multipoint()- resulting table contains one geometry column, representing start end points MULTIPOINT!!! !!!st_linestring() - resulting table contains one geometry column, representing line start end points LINESTRING!!!","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_convert_table_to_sf.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Transforms the data frame trips_output (from read_output_trips) from tibble to sf (table with geometry features) — process_convert_table_to_sf","text":"sf object (data frame geometries depending geometry.type)","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_convert_time.html","id":null,"dir":"Reference","previous_headings":"","what":"Converts time column specified in time_column to numeric representation of minutes, hours or seconds — process_convert_time","title":"Converts time column specified in time_column to numeric representation of minutes, hours or seconds — process_convert_time","text":"Default output_trips table time columns(dep_time, trav_time, wait_time) 'hms' format. convert type numeric, specify time_column converted, unit time_format. Acceptable units \"hour\", \"minute\" \"second\".","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_convert_time.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Converts time column specified in time_column to numeric representation of minutes, hours or seconds — process_convert_time","text":"","code":"process_convert_time( trips_table, time_format = \"hour\", time_column = \"dep_time\" )"},{"path":"https://vsp.berlin/matsim-r/reference/process_convert_time.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Converts time column specified in time_column to numeric representation of minutes, hours or seconds — process_convert_time","text":"trips_table tibble output_trips (read_output_trips) time_format char, defines time unit used (\"hour\", \"minute\", \"second\") time_column char, name column table converted (dep_time, trav_time, wait_time)","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_convert_time.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Converts time column specified in time_column to numeric representation of minutes, hours or seconds — process_convert_time","text":"tibble, containing column specified time_format","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_filter_by_shape.html","id":null,"dir":"Reference","previous_headings":"","what":"Filters trips_table(from ,read_output_trips) depending by location using a shapefile — process_filter_by_shape","title":"Filters trips_table(from ,read_output_trips) depending by location using a shapefile — process_filter_by_shape","text":"Uses output_trips sf object (can created using function st_read()), transforms objects match mutual coordinate system (crs) filters trips output_trips depending spatial type: spatial_type=\"inside\" returns table contains trips inside given shape spatial_type=\"originating\" returns table contains trips start inside shape end outside shape spatial_type=\"destinating\" returns table contains trips end inside shape start outside shape spatial_type=\"outside\" returns table contains trips start end outside given shape","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_filter_by_shape.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Filters trips_table(from ,read_output_trips) depending by location using a shapefile — process_filter_by_shape","text":"","code":"process_filter_by_shape(trips_table, shape_table, crs, spatial_type = \"inside\")"},{"path":"https://vsp.berlin/matsim-r/reference/process_filter_by_shape.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Filters trips_table(from ,read_output_trips) depending by location using a shapefile — process_filter_by_shape","text":"trips_table tibble trips_output (read_output_trips) crs numeric representation EPSG code proj4string corresponding coordinate system trip coordinates, can found network file output directory MATSim simulation spatial_type bool, defines trips conclude (see description) shape_Table sf object(data frame geometries), can created using st_read()","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_filter_by_shape.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Filters trips_table(from ,read_output_trips) depending by location using a shapefile — process_filter_by_shape","text":"tibble, filtered trips depending shapeTable spatial types (see description)","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_get_crs_from_config.html","id":null,"dir":"Reference","previous_headings":"","what":"Reads the coordinate reference system from a MATSim output directory (output_config.xml) — process_get_crs_from_config","title":"Reads the coordinate reference system from a MATSim output directory (output_config.xml) — process_get_crs_from_config","text":"Reads coordinate reference system MATSim output directory (output_config.xml)","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_get_crs_from_config.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Reads the coordinate reference system from a MATSim output directory (output_config.xml) — process_get_crs_from_config","text":"","code":"process_get_crs_from_config(config_path)"},{"path":"https://vsp.berlin/matsim-r/reference/process_get_crs_from_config.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Reads the coordinate reference system from a MATSim output directory (output_config.xml) — process_get_crs_from_config","text":"config_path specifies path configuration file","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_get_crs_from_config.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Reads the coordinate reference system from a MATSim output directory (output_config.xml) — process_get_crs_from_config","text":"EPSG code coordinate reference system","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_get_mainmode_distribution.html","id":null,"dir":"Reference","previous_headings":"","what":"Calculates main mode distribution — process_get_mainmode_distribution","title":"Calculates main mode distribution — process_get_mainmode_distribution","text":"process_get_mainmode_distribution function calculates distribution main modes given trips_table. provides insights frequency percentage main mode within dataset.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_get_mainmode_distribution.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Calculates main mode distribution — process_get_mainmode_distribution","text":"","code":"process_get_mainmode_distribution(trips_table, percentage = FALSE)"},{"path":"https://vsp.berlin/matsim-r/reference/process_get_mainmode_distribution.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Calculates main mode distribution — process_get_mainmode_distribution","text":"trips_table tible output_trips (read_output_trips) percentage boolean, default FALSE, sets output given percentage","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_get_mainmode_distribution.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Calculates main mode distribution — process_get_mainmode_distribution","text":"tibble provides distribution main modes input trips_table.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_get_mainmode_distribution.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Calculates main mode distribution — process_get_mainmode_distribution","text":"default, function counts occurrences main mode trips_table tibble returns counts unique main mode. Alternatively, percentage parameter set TRUE, function normalizes counts represent percentage distribution main mode within dataset.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_get_od_matrix.html","id":null,"dir":"Reference","previous_headings":"","what":"Creates an origin/destination matrix either in conventional form (row names = origin, column names = destination)\nor for simwrapper (origin and destination as columns) — process_get_od_matrix","title":"Creates an origin/destination matrix either in conventional form (row names = origin, column names = destination)\nor for simwrapper (origin and destination as columns) — process_get_od_matrix","text":"Creates origin/destination matrix either conventional form (row names = origin, column names = destination) simwrapper (origin destination columns)","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_get_od_matrix.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Creates an origin/destination matrix either in conventional form (row names = origin, column names = destination)\nor for simwrapper (origin and destination as columns) — process_get_od_matrix","text":"","code":"process_get_od_matrix( trips_table, shape_path, crs, dump.output.to = matsimDumpOutputDirectory, simwrapper = FALSE, colnames = \"numeric\", outer = FALSE )"},{"path":"https://vsp.berlin/matsim-r/reference/process_get_od_matrix.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Creates an origin/destination matrix either in conventional form (row names = origin, column names = destination)\nor for simwrapper (origin and destination as columns) — process_get_od_matrix","text":"trips_table tibble trips_output (read_output_trips) shape_path string, full path shapefile (.shp) (shape files made several files name folder also needs include .dbf file) crs numeric, coordinate system form EPSG code proj4string, can found MATSim network file dump.output.string, path folder save .csv file simwrapper boolean, creates output format used simwrapper path shapefile specified colnames string, column names can specified (.e. fit shape file), numbered outer boolean, determines flows outside shapefile used, standard value FALSE","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_get_od_matrix.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Creates an origin/destination matrix either in conventional form (row names = origin, column names = destination)\nor for simwrapper (origin and destination as columns) — process_get_od_matrix","text":"tibble origin/destination matrix","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_get_travdistance_distribution.html","id":null,"dir":"Reference","previous_headings":"","what":"Get Travel Distance Distribution by Main Mode — process_get_travdistance_distribution","title":"Get Travel Distance Distribution by Main Mode — process_get_travdistance_distribution","text":"process_get_travdistance_distribution function calculates distribution travel distances based main modes given trips_table tibble. provides insights average distance traveled main mode.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_get_travdistance_distribution.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get Travel Distance Distribution by Main Mode — process_get_travdistance_distribution","text":"","code":"process_get_travdistance_distribution(trips_table, euclidean = FALSE)"},{"path":"https://vsp.berlin/matsim-r/reference/process_get_travdistance_distribution.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get Travel Distance Distribution by Main Mode — process_get_travdistance_distribution","text":"trips_table tibble output_trips (read_output_trips) euclidean Logical value indicating whether calculate average euclidean distance travel distance. Default FALSE, calculates average traveled distance.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_get_travdistance_distribution.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get Travel Distance Distribution by Main Mode — process_get_travdistance_distribution","text":"tibble containing main_mode column representing unique main modes avg_dist column representing average travel distance main mode.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_get_travelwaittime_by_mainmode.html","id":null,"dir":"Reference","previous_headings":"","what":"Get Travel and Wait Time by Main Mode — process_get_travelwaittime_by_mainmode","title":"Get Travel and Wait Time by Main Mode — process_get_travelwaittime_by_mainmode","text":"process_get_travelwaittime_by_mainmode function calculates average travel time average wait time main mode given trips_table tibble.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_get_travelwaittime_by_mainmode.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get Travel and Wait Time by Main Mode — process_get_travelwaittime_by_mainmode","text":"","code":"process_get_travelwaittime_by_mainmode(trips_table, time_format = \"minute\")"},{"path":"https://vsp.berlin/matsim-r/reference/process_get_travelwaittime_by_mainmode.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get Travel and Wait Time by Main Mode — process_get_travelwaittime_by_mainmode","text":"trips_table tibble output_trips (read_output_trips) time_format character string indicating desired time format output. options \"minute\", \"hour\", \"second\". default \"minute\".","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_get_travelwaittime_by_mainmode.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get Travel and Wait Time by Main Mode — process_get_travelwaittime_by_mainmode","text":"tibble containing main_mode column representing unique main modes, trav_time_avg column representing average travel time main mode, wait_time_avg column representing average wait time main mode.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_rename_category.html","id":null,"dir":"Reference","previous_headings":"","what":"Replace Matching Categories of any column with United Name in Tibble — process_rename_category","title":"Replace Matching Categories of any column with United Name in Tibble — process_rename_category","text":"process_rename_category function takes tibble, trips_table, input replaces occurrences categories match given template another name provided united_name. function provides flexibility specify multiple category templates united single name.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_rename_category.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Replace Matching Categories of any column with United Name in Tibble — process_rename_category","text":"","code":"process_rename_category( trips_table, unite_template = character(0), united_name = \"united\", column = \"main_mode\" )"},{"path":"https://vsp.berlin/matsim-r/reference/process_rename_category.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Replace Matching Categories of any column with United Name in Tibble — process_rename_category","text":"trips_table tible output_trips (read_output_trips) unite_template vector character string, representing pattern match categories united_name character string, represent new category occurrences matched unite_modes column tibble column name, used occurrences renaming","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_rename_category.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Replace Matching Categories of any column with United Name in Tibble — process_rename_category","text":"modified trips table tibble","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_rename_mainmodes.html","id":null,"dir":"Reference","previous_headings":"","what":"Replace Matching Categories of main_mode with United Name in Tibble — process_rename_mainmodes","title":"Replace Matching Categories of main_mode with United Name in Tibble — process_rename_mainmodes","text":"process_rename_mainmodes function takes tibble, trips_table, input replaces occurrences column main_mode categories match given template another name provided united_name. function provides flexibility specify multiple category templates united single name.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_rename_mainmodes.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Replace Matching Categories of main_mode with United Name in Tibble — process_rename_mainmodes","text":"","code":"process_rename_mainmodes( trips_table, unite_modes = character(0), united_name = \"united\" )"},{"path":"https://vsp.berlin/matsim-r/reference/process_rename_mainmodes.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Replace Matching Categories of main_mode with United Name in Tibble — process_rename_mainmodes","text":"trips_table tibble output_trips (read_output_trips) unite_modes vector character strings, changes names chosen modes column main_mode new chosen name (.e. drtNorth drtSouth drt) united_name character string, specifies name united mode","code":""},{"path":"https://vsp.berlin/matsim-r/reference/process_rename_mainmodes.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Replace Matching Categories of main_mode with United Name in Tibble — process_rename_mainmodes","text":"tibble new main_mode representation","code":""},{"path":"https://vsp.berlin/matsim-r/reference/readCounts.html","id":null,"dir":"Reference","previous_headings":"","what":"Load a MATSim Counts file into memory — readCounts","title":"Load a MATSim Counts file into memory — readCounts","text":"Loads MATSim Counts XML-file tibble memory","code":""},{"path":"https://vsp.berlin/matsim-r/reference/readCounts.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Load a MATSim Counts file into memory — readCounts","text":"","code":"readCounts(file)"},{"path":"https://vsp.berlin/matsim-r/reference/readCounts.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Load a MATSim Counts file into memory — readCounts","text":"file File load. Must .xml file","code":""},{"path":"https://vsp.berlin/matsim-r/reference/readCounts.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Load a MATSim Counts file into memory — readCounts","text":"tibble MATSim link id (\"loc_id\") key","code":""},{"path":"https://vsp.berlin/matsim-r/reference/readLinkStats.html","id":null,"dir":"Reference","previous_headings":"","what":"Load a MATSim linkstats file into memory — readLinkStats","title":"Load a MATSim linkstats file into memory — readLinkStats","text":"Loads linkstats tsv file created LinkStats class dataframe memory. Counts can provided time bin. Counts can provided qsim mode. argument networkModes used select filter columns.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/readLinkStats.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Load a MATSim linkstats file into memory — readLinkStats","text":"","code":"readLinkStats(runId, file, sampleSize = 0.25)"},{"path":"https://vsp.berlin/matsim-r/reference/readLinkStats.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Load a MATSim linkstats file into memory — readLinkStats","text":"runId Id tag columns DTV file File load. Must .csv .tsv file comma separator sampleSize sample size MATSim scenario scale DTV values","code":""},{"path":"https://vsp.berlin/matsim-r/reference/readLinkStats.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Load a MATSim linkstats file into memory — readLinkStats","text":"Tibble link stats qsim mode","code":""},{"path":"https://vsp.berlin/matsim-r/reference/readPersonsTable.html","id":null,"dir":"Reference","previous_headings":"","what":"Load MATSim output_persons table into memory — readPersonsTable","title":"Load MATSim output_persons table into memory — readPersonsTable","text":"Loads MATSim CSV output_persons file archive, creating tibble columns csv file copied + adopted code readTripsTable tripsOutput.R","code":""},{"path":"https://vsp.berlin/matsim-r/reference/readPersonsTable.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Load MATSim output_persons table into memory — readPersonsTable","text":"","code":"readPersonsTable(input_path = \".\", n_max = Inf)"},{"path":"https://vsp.berlin/matsim-r/reference/readPersonsTable.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Load MATSim output_persons table into memory — readPersonsTable","text":"input_path character string, path local MATSim output directory, persons csv directly, http link file. n_max integer, maximum number lines read within output_persons","code":""},{"path":"https://vsp.berlin/matsim-r/reference/readPersonsTable.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Load MATSim output_persons table into memory — readPersonsTable","text":"tibble output_persons","code":""},{"path":"https://vsp.berlin/matsim-r/reference/read_config.html","id":null,"dir":"Reference","previous_headings":"","what":"Load MATSIM config file into Memory — read_config","title":"Load MATSIM config file into Memory — read_config","text":"Loads MATSim xml config file archive, creating list parameters xml file","code":""},{"path":"https://vsp.berlin/matsim-r/reference/read_config.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Load MATSIM config file into Memory — read_config","text":"","code":"read_config(input_path = \".\", n_max = Inf)"},{"path":"https://vsp.berlin/matsim-r/reference/read_config.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Load MATSIM config file into Memory — read_config","text":"input_path character string, path matsim output directory http link file. n_max integer, maximum number lines read within output_trips","code":""},{"path":"https://vsp.berlin/matsim-r/reference/read_config.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Load MATSIM config file into Memory — read_config","text":"tibble trips_output","code":""},{"path":"https://vsp.berlin/matsim-r/reference/read_network.html","id":null,"dir":"Reference","previous_headings":"","what":"Load MATSim network into memory — read_network","title":"Load MATSim network into memory — read_network","text":"Loads MATSim XML network file, creating nodes tibble links tibble. node link attribute records network stored additional columns respective node link tibbles.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/read_network.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Load MATSim network into memory — read_network","text":"","code":"read_network(filename)"},{"path":"https://vsp.berlin/matsim-r/reference/read_network.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Load MATSim network into memory — read_network","text":"filename File load. Can XML gzipped XML","code":""},{"path":"https://vsp.berlin/matsim-r/reference/read_network.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Load MATSim network into memory — read_network","text":"\"nodes\" \"links\" tibbles list object.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/read_network.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Load MATSim network into memory — read_network","text":"links table automatically joined nodes table node x/y coordinates (node attributes) available links table without additional processing.","code":""},{"path":"https://vsp.berlin/matsim-r/reference/read_output_persons.html","id":null,"dir":"Reference","previous_headings":"","what":"Load MATSim output_persons table into memory — read_output_persons","title":"Load MATSim output_persons table into memory — read_output_persons","text":"Loads MATSim CSV output_persons file archive, creating tibble columns csv file copied + adopted code readTripsTable tripsOutput.R","code":""},{"path":"https://vsp.berlin/matsim-r/reference/read_output_persons.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Load MATSim output_persons table into memory — read_output_persons","text":"","code":"read_output_persons(input_path = \".\", n_max = Inf)"},{"path":"https://vsp.berlin/matsim-r/reference/read_output_persons.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Load MATSim output_persons table into memory — read_output_persons","text":"input_path character string, path local MATSim output directory, persons csv directly, http link file. n_max integer, maximum number lines read within output_persons","code":""},{"path":"https://vsp.berlin/matsim-r/reference/read_output_persons.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Load MATSim output_persons table into memory — read_output_persons","text":"tibble output_persons","code":""},{"path":"https://vsp.berlin/matsim-r/reference/read_output_trips.html","id":null,"dir":"Reference","previous_headings":"","what":"Load MATSim output_trips table into memory — read_output_trips","title":"Load MATSim output_trips table into memory — read_output_trips","text":"Loads MATSim output_trips.csv file archive creating tibble","code":""},{"path":"https://vsp.berlin/matsim-r/reference/read_output_trips.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Load MATSim output_trips table into memory — read_output_trips","text":"","code":"read_output_trips(input_path = \".\", n_max = Inf)"},{"path":"https://vsp.berlin/matsim-r/reference/read_output_trips.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Load MATSim output_trips table into memory — read_output_trips","text":"input_path character string, path MATSim output directory http link file n_max optional, integer, maximum number lines read, standard value Inf","code":""},{"path":"https://vsp.berlin/matsim-r/reference/read_output_trips.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Load MATSim output_trips table into memory — read_output_trips","text":"tibble output_trips","code":""},{"path":"https://vsp.berlin/matsim-r/reference/symlog_trans.html","id":null,"dir":"Reference","previous_headings":"","what":"A function to create symlog scaling for a plot — symlog_trans","title":"A function to create symlog scaling for a plot — symlog_trans","text":"Can used symlog scale axis ggplot object. called createCountScatterPlot. Note function taken Stackoverflow! informations, see thread : https://stackoverflow.com/questions/14613355/--get-something-like-matplotlibs-symlog-scale--ggplot--lattice","code":""},{"path":"https://vsp.berlin/matsim-r/reference/symlog_trans.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"A function to create symlog scaling for a plot — symlog_trans","text":"","code":"symlog_trans(base = 10, thr = 1, scale = 1)"},{"path":"https://vsp.berlin/matsim-r/reference/symlog_trans.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"A function to create symlog scaling for a plot — symlog_trans","text":"base base log thr threshold data scaled log","code":""}] diff --git a/docs/sitemap.xml b/docs/sitemap.xml index f69b7fc..b32c845 100644 --- a/docs/sitemap.xml +++ b/docs/sitemap.xml @@ -6,6 +6,18 @@ https://vsp.berlin/matsim-r/LICENSE.html + + https://vsp.berlin/matsim-r/articles/Exampleproject.html + + + https://vsp.berlin/matsim-r/articles/Introduction.html + + + https://vsp.berlin/matsim-r/articles/Namings.html + + + https://vsp.berlin/matsim-r/articles/index.html + https://vsp.berlin/matsim-r/authors.html @@ -13,118 +25,130 @@ https://vsp.berlin/matsim-r/index.html - https://vsp.berlin/matsim-r/reference/compareAverageTravelWait.html + https://vsp.berlin/matsim-r/reference/boxplotScoreDifferences.html + + + https://vsp.berlin/matsim-r/reference/createCountScatterPlot.html - https://vsp.berlin/matsim-r/reference/compareBasePolicyOutput.html + https://vsp.berlin/matsim-r/reference/generateXYHexagonYaml.html - https://vsp.berlin/matsim-r/reference/compareBasePolicyShapeOutput.html + https://vsp.berlin/matsim-r/reference/index.html - https://vsp.berlin/matsim-r/reference/compareModalDistanceDistribution.html + https://vsp.berlin/matsim-r/reference/matsimr-deprecated.html - https://vsp.berlin/matsim-r/reference/compareTripTypesBarChart.html + https://vsp.berlin/matsim-r/reference/mergeCountsAndLinks.html - https://vsp.berlin/matsim-r/reference/createCountScatterPlot.html + https://vsp.berlin/matsim-r/reference/plot_arrtime_by_act.html - https://vsp.berlin/matsim-r/reference/deriveODMatrix.html + https://vsp.berlin/matsim-r/reference/plot_compare_count_by_spatialcat_barchart.html - https://vsp.berlin/matsim-r/reference/filterByRegion.html + https://vsp.berlin/matsim-r/reference/plot_compare_distcat_by_mainmode_barchart.html - https://vsp.berlin/matsim-r/reference/generateXYHexagonYaml.html + https://vsp.berlin/matsim-r/reference/plot_compare_mainmode_barchart.html - https://vsp.berlin/matsim-r/reference/generate_html_docs.html + https://vsp.berlin/matsim-r/reference/plot_compare_mainmode_sankey.html - https://vsp.berlin/matsim-r/reference/getCrsFromConfig.html + https://vsp.berlin/matsim-r/reference/plot_compare_score_boxplot.html - https://vsp.berlin/matsim-r/reference/index.html + https://vsp.berlin/matsim-r/reference/plot_compare_travelwaittime_by_mainmode.html - https://vsp.berlin/matsim-r/reference/loadNetwork.html + https://vsp.berlin/matsim-r/reference/plot_compare_travelwaittime_by_mainmode_barchart.html - https://vsp.berlin/matsim-r/reference/mergeCountsAndLinks.html + https://vsp.berlin/matsim-r/reference/plot_deptime_by_act.html + + + https://vsp.berlin/matsim-r/reference/plot_distance_by_mainmode_barchart.html - https://vsp.berlin/matsim-r/reference/plotActivityEndTimes.html + https://vsp.berlin/matsim-r/reference/plot_distance_by_spatialcat_barchart.html - https://vsp.berlin/matsim-r/reference/plotArrivalTimesPerTripPurpose.html + https://vsp.berlin/matsim-r/reference/plot_distcat_by_mainmode_barchart.html - https://vsp.berlin/matsim-r/reference/plotAverageTravelWait.html + https://vsp.berlin/matsim-r/reference/plot_mainmode_barchart.html - https://vsp.berlin/matsim-r/reference/plotDepartureTimesPerTripPurpose.html + https://vsp.berlin/matsim-r/reference/plot_mainmode_piechart.html - https://vsp.berlin/matsim-r/reference/plotDistanceTraveledByType.html + https://vsp.berlin/matsim-r/reference/plot_map_trips.html - https://vsp.berlin/matsim-r/reference/plotEndActCountByArrTime.html + https://vsp.berlin/matsim-r/reference/plot_map_trips_by_spatialcat.html - https://vsp.berlin/matsim-r/reference/plotMapWithTrips.html + https://vsp.berlin/matsim-r/reference/plot_spatialtype_by_shape_piechart.html - https://vsp.berlin/matsim-r/reference/plotMapWithTripsType.html + https://vsp.berlin/matsim-r/reference/plot_travelwaittime_mean_barchart.html - https://vsp.berlin/matsim-r/reference/plotModalDistanceDistribution.html + https://vsp.berlin/matsim-r/reference/plot_trips_count_by_deptime_and_mainmode_linechart.html - https://vsp.berlin/matsim-r/reference/plotModalShiftBar.html + https://vsp.berlin/matsim-r/reference/prepareComparisonSimwrapperDashboardFromTable.html - https://vsp.berlin/matsim-r/reference/plotModalShiftSankey.html + https://vsp.berlin/matsim-r/reference/prepareSimwrapperDashboardFromFolder.html - https://vsp.berlin/matsim-r/reference/plotModalSplitBarChart.html + https://vsp.berlin/matsim-r/reference/prepareSimwrapperDashboardFromTable.html - https://vsp.berlin/matsim-r/reference/plotModalSplitPieChart.html + https://vsp.berlin/matsim-r/reference/processDtvEstimationQuality.html - https://vsp.berlin/matsim-r/reference/plotStartActCountByDepTime.html + https://vsp.berlin/matsim-r/reference/processLinkStatsDtvDistribution.html - https://vsp.berlin/matsim-r/reference/plotTripCountByDepTime.html + https://vsp.berlin/matsim-r/reference/process_append_distcat.html - https://vsp.berlin/matsim-r/reference/plotTripDistanceByMode.html + https://vsp.berlin/matsim-r/reference/process_append_spatialcat.html - https://vsp.berlin/matsim-r/reference/plotTripDistancedByType.html + https://vsp.berlin/matsim-r/reference/process_convert_table_to_sf.html - https://vsp.berlin/matsim-r/reference/plotTripTypesPieChart.html + https://vsp.berlin/matsim-r/reference/process_convert_time.html - https://vsp.berlin/matsim-r/reference/plotTripsByDistance.html + https://vsp.berlin/matsim-r/reference/process_filter_by_shape.html - https://vsp.berlin/matsim-r/reference/prepareComparisonSimwrapperDashboardFromTable.html + https://vsp.berlin/matsim-r/reference/process_get_crs_from_config.html - https://vsp.berlin/matsim-r/reference/prepareSimwrapperDashboardFromFolder.html + https://vsp.berlin/matsim-r/reference/process_get_mainmode_distribution.html - https://vsp.berlin/matsim-r/reference/prepareSimwrapperDashboardFromTable.html + https://vsp.berlin/matsim-r/reference/process_get_od_matrix.html - https://vsp.berlin/matsim-r/reference/processDtvEstimationQuality.html + https://vsp.berlin/matsim-r/reference/process_get_travdistance_distribution.html - https://vsp.berlin/matsim-r/reference/processLinkStatsDtvDistribution.html + https://vsp.berlin/matsim-r/reference/process_get_travelwaittime_by_mainmode.html + + + https://vsp.berlin/matsim-r/reference/process_rename_category.html + + + https://vsp.berlin/matsim-r/reference/process_rename_mainmodes.html https://vsp.berlin/matsim-r/reference/readCounts.html @@ -136,12 +160,18 @@ https://vsp.berlin/matsim-r/reference/readPersonsTable.html - https://vsp.berlin/matsim-r/reference/readTripsTable.html + https://vsp.berlin/matsim-r/reference/read_config.html - https://vsp.berlin/matsim-r/reference/symlog_trans.html + https://vsp.berlin/matsim-r/reference/read_network.html - https://vsp.berlin/matsim-r/reference/transformToSf.html + https://vsp.berlin/matsim-r/reference/read_output_persons.html + + + https://vsp.berlin/matsim-r/reference/read_output_trips.html + + + https://vsp.berlin/matsim-r/reference/symlog_trans.html diff --git a/man/compareAverageTravelWait.Rd b/man/compareAverageTravelWait.Rd deleted file mode 100644 index ca9c707..0000000 --- a/man/compareAverageTravelWait.Rd +++ /dev/null @@ -1,37 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{compareAverageTravelWait} -\alias{compareAverageTravelWait} -\title{Bar Chart with main_mode on x-axis and average travel/wait time on y-axis} -\usage{ -compareAverageTravelWait( - tripsTable1, - tripsTable2, - unite.columns = character(0), - united.name = "united", - dump.output.to = matsimDumpOutputDirectory, - only.files = FALSE -) -} -\arguments{ -\item{tripsTable1}{tible of trips_output (from readTripsTable())} - -\item{tripsTable2}{tible of trips_output (from readTripsTable())} - -\item{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} - -\item{united.name}{character string, if columns were united, you can specify name for the resulting column in chart} - -\item{dump.output.to}{folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored} - -\item{only.files}{boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly} -} -\value{ -Bar Chart plot of average time spent on travel/wait -} -\description{ -Takes Table trips_output (from readTripsTable()), -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') -} diff --git a/man/compareBasePolicyOutput.Rd b/man/compareBasePolicyOutput.Rd deleted file mode 100644 index 6190028..0000000 --- a/man/compareBasePolicyOutput.Rd +++ /dev/null @@ -1,28 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{compareBasePolicyOutput} -\alias{compareBasePolicyOutput} -\title{Chooses a function to compare output_trips from the folders. -baseFolder contains all base outputs, policyFolder contains all policy outputs.} -\usage{ -compareBasePolicyOutput( - baseFolder, - policyFolder, - dump.output.to = matsimDumpOutputDirectory -) -} -\arguments{ -\item{baseFolder}{specifies data source folder with multiple base output_trips} - -\item{policyFolder}{specifies data source folder with multiple policy output_trips} - -\item{dump.output.to}{that saves result of all comparisons between each base and each policy. -For now it creates plotModalShiftBar() for the output_trips} -} -\value{ -list of tibbles, list of all base and policy output_trips as tibble -} -\description{ -Chooses a function to compare output_trips from the folders. -baseFolder contains all base outputs, policyFolder contains all policy outputs. -} diff --git a/man/compareBasePolicyShapeOutput.Rd b/man/compareBasePolicyShapeOutput.Rd deleted file mode 100644 index 41278b9..0000000 --- a/man/compareBasePolicyShapeOutput.Rd +++ /dev/null @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{compareBasePolicyShapeOutput} -\alias{compareBasePolicyShapeOutput} -\title{Chooses a function to compare output_trips from the folders. -baseFolder contains all base outputs, policyFolder contains all policy outputs.} -\usage{ -compareBasePolicyShapeOutput( - baseFolder, - policyFolder, - shapeFilePath, - crs, - dump.output.to = matsimDumpOutputDirectory -) -} -\arguments{ -\item{baseFolder}{specifies data source folder with multiple base output_trips} - -\item{policyFolder}{specifies data source folder with multiple policy output_trips} - -\item{shapeFilePath}{specifies shapeFile used for comparison} - -\item{crs}{numeric of EPSG code or proj4string, can be found in network/config file from output directory of MATSim simulation} - -\item{dump.output.to}{that saves result of all comparisons between each base and each policy. -For now it creates plotModalShiftBar() for the output_trips} -} -\value{ -list of tibbles, list of all base and policy output_trips as tibble -} -\description{ -Chooses a function to compare output_trips from the folders. -baseFolder contains all base outputs, policyFolder contains all policy outputs. -} diff --git a/man/compareModalDistanceDistribution.Rd b/man/compareModalDistanceDistribution.Rd deleted file mode 100644 index 00f0e9c..0000000 --- a/man/compareModalDistanceDistribution.Rd +++ /dev/null @@ -1,37 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{compareModalDistanceDistribution} -\alias{compareModalDistanceDistribution} -\title{Bar Chart with distance travelled on x-axis and difference of number of trips on y-axis} -\usage{ -compareModalDistanceDistribution( - tripsTable1, - tripsTable2, - unite.columns = character(0), - united.name = "united", - dump.output.to = matsimDumpOutputDirectory, - only.files = FALSE -) -} -\arguments{ -\item{tripsTable1}{tible of trips_output (from readTripsTable()), number of trips of this table will be extracted from number of trips of tripsTable1} - -\item{tripsTable2}{tible of trips_output (from readTripsTable()), from number of trips of this table number of trips of tripsTable1 will be extracted} - -\item{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} - -\item{united.name}{character string, if columns were united, you can specify name for the resulting column in chart} - -\item{dump.output.to}{folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored} - -\item{only.files}{boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly} -} -\value{ -Bar Chart plot of count of trips among distance travelled -} -\description{ -Takes 2 Tables trips_output (from readTripsTable()), -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') -} diff --git a/man/compareTripTypesBarChart.Rd b/man/compareTripTypesBarChart.Rd deleted file mode 100644 index 8b0ef5e..0000000 --- a/man/compareTripTypesBarChart.Rd +++ /dev/null @@ -1,33 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{compareTripTypesBarChart} -\alias{compareTripTypesBarChart} -\title{Creates BarChart of changing trip types(originating,transit etc) between 2 tables -and saves output to dump.output.to} -\usage{ -compareTripTypesBarChart( - tripsTable1, - tripsTable2, - shapeTable, - crs, - dump.output.to = matsimDumpOutputDirectory -) -} -\arguments{ -\item{tripsTable1}{tibble of trips_output (from readTripsTable(),f.e. base case)} - -\item{tripsTable2}{tibble of trips_output (from readTripsTable(),f.e. policy case)} - -\item{shapeTable}{sf object(data.frame with geometries), can be received by using st_read(path_to_geographical_file)} - -\item{crs}{numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation} - -\item{dump.output.to}{folder that saves resulting image of BarChart} -} -\value{ -plot with percentage of each type of trips between 2 tables -} -\description{ -Creates BarChart of changing trip types(originating,transit etc) between 2 tables -and saves output to dump.output.to -} diff --git a/man/createCountScatterPlot.Rd b/man/createCountScatterPlot.Rd index c53ea42..5018913 100644 --- a/man/createCountScatterPlot.Rd +++ b/man/createCountScatterPlot.Rd @@ -25,11 +25,11 @@ A ggplot Scatterplotplot, which can be adjusted, if needed. } \description{ Takes a tibble from mergeCountsAndLinks. -A scatterplot with counts on the x axis and matsim dtv on the y axis is created and colored +A scatterplot with counts on the x axis and MATSim dtv on the y axis is created and colored by the road type. -Lower and upper Limits define the section which is considered as an 'exact' estimation. Limits +Lower and upper limits define the section which is considered an 'exact' estimation. Limits are defined by custom formulas. } \details{ -The function calls the matsim-r function processDtvEstimationQuality which is handeling the limits. +The function calls the matsim-r function processDtvEstimationQuality which is handling the limits. } diff --git a/man/deriveODMatrix.Rd b/man/deriveODMatrix.Rd deleted file mode 100644 index a616f2e..0000000 --- a/man/deriveODMatrix.Rd +++ /dev/null @@ -1,37 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{deriveODMatrix} -\alias{deriveODMatrix} -\title{Creates an instance of ODMatrix(origin/destination) in conventional form or for the simwrapper} -\usage{ -deriveODMatrix( - tripsTable, - shapePath, - crs, - dump.output.to = matsimDumpOutputDirectory, - simwrapper = FALSE, - colnames = "numeric", - outer = FALSE -) -} -\arguments{ -\item{tripsTable}{table of output trips(from readTripsTable) or path to trips_output file} - -\item{shapePath}{full path to shapefile (if simwrapper TRUE, folder with shapeFile should contain also .dbf with the same name)} - -\item{crs}{numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation} - -\item{dump.output.to}{path to a folder to save csv file of ODMatrix} - -\item{simwrapper}{create output in a simwrapper form if set to path of the shapefile} - -\item{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} - -\item{outer}{logical that represent if the table should contain outside flow of the shape, it isn't} -} -\value{ -tibble of origin/destination matrix -} -\description{ -Creates an instance of ODMatrix(origin/destination) in conventional form or for the simwrapper -} diff --git a/man/figures/dataflow.png b/man/figures/dataflow.png new file mode 100644 index 0000000..02f8cf1 Binary files /dev/null and b/man/figures/dataflow.png differ diff --git a/man/filterByRegion.Rd b/man/filterByRegion.Rd deleted file mode 100644 index 5554dca..0000000 --- a/man/filterByRegion.Rd +++ /dev/null @@ -1,38 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{filterByRegion} -\alias{filterByRegion} -\title{Filtering of trips_table(from readTripsTable) depending on how they located in given shape} -\usage{ -filterByRegion( - tripsTable, - shapeTable, - crs, - start.inshape = TRUE, - end.inshape = TRUE -) -} -\arguments{ -\item{tripsTable}{tibble of trips_output (from readTripsTable())} - -\item{shapeTable}{sf object(data.frame with geometries), can be received by using st_read(path_to_geographical_file)} - -\item{crs}{numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation} - -\item{start.inshape}{bool, defines trips to conclude (see Description)} - -\item{end.inshape}{bool, defines trips to conclude (see Description)} -} -\value{ -tibble, with filtered trips depending on shapeTable and special flags (see Description) -} -\description{ -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 -} diff --git a/man/generateXYHexagonYaml.Rd b/man/generateXYHexagonYaml.Rd index a28b5fb..cc56d90 100644 --- a/man/generateXYHexagonYaml.Rd +++ b/man/generateXYHexagonYaml.Rd @@ -11,11 +11,11 @@ generateXYHexagonYaml( ) } \arguments{ -\item{pathToOutputTrips}{specifies path to a data source of output_trips} +\item{pathToOutputTrips}{file path to output_trips.csv file} -\item{crs}{specifies an coordinate reference system of output_trips} +\item{crs}{specifies the coordinate reference system of output_trips} -\item{dump.output.to}{path to an folder with dashboard} +\item{dump.output.to}{path to a folder with simwrapper dashboard} } \value{ changed file diff --git a/man/getCrsFromConfig.Rd b/man/getCrsFromConfig.Rd deleted file mode 100644 index 8aa7289..0000000 --- a/man/getCrsFromConfig.Rd +++ /dev/null @@ -1,19 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{getCrsFromConfig} -\alias{getCrsFromConfig} -\title{Reads an coordinate referenec system of MATSim output directory -from output_config.xml} -\usage{ -getCrsFromConfig(folder) -} -\arguments{ -\item{folder}{specifies path to find config} -} -\value{ -code of coordinate reference system -} -\description{ -Reads an coordinate referenec system of MATSim output directory -from output_config.xml -} diff --git a/man/matsimr-deprecated.Rd b/man/matsimr-deprecated.Rd new file mode 100644 index 0000000..f03e278 --- /dev/null +++ b/man/matsimr-deprecated.Rd @@ -0,0 +1,518 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/network.R, R/output_persons.R, R/output_trips.R +\docType{package} +\name{loadNetwork} +\alias{loadNetwork} +\alias{readPersonsTable} +\alias{boxplotScoreDifferences} +\alias{matsimr-deprecated} +\alias{plotModalSplitPieChart} +\alias{plotModalSplitBarChart} +\alias{readTripsTable} +\alias{plotAverageTravelWait} +\alias{compareAverageTravelWait} +\alias{plotModalDistanceDistribution} +\alias{compareModalDistanceDistribution} +\alias{plotTripDistanceByMode} +\alias{plotTripCountByDepTime} +\alias{plotActivityEndTimes} +\alias{plotArrivalTimesPerTripPurpose} +\alias{plotDepartureTimesPerTripPurpose} +\alias{plotTripDistancedByType} +\alias{plotModalShiftSankey} +\alias{plotModalShiftBar} +\alias{plotMapWithFilteredTrips} +\alias{plotMapWithTrips} +\alias{plotTripTypesPieChart} +\alias{compareTripTypesBarChart} +\alias{plotMapWithTripsType} +\alias{compareBasePolicyOutput} +\alias{compareBasePolicyShapeOutput} +\alias{appendDistanceCategory} +\alias{filterByRegion} +\alias{deriveODMatrix} +\alias{getCrsFromConfig} +\alias{transformToSf} +\title{Load MATSim network into memory} +\usage{ +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()) +} +\arguments{ +\item{filename}{File to load. Can be XML or gzipped XML} + +\item{input_path}{character string, path to MATSim output directory or http link to the file.} + +\item{n_max}{integer, maximum number of lines to read within output_trips} + +\item{personTibble_base}{persons tibble of the base case, can be loaded with readPersonsTable.} + +\item{personTibble_policy}{persons tibble of the policy case, can be loaded with readPersonsTable.} + +\item{tripsTable}{table of output trips(from \link{read_output_trips}) or path to trips_output file} + +\item{unite.columns}{vector of character string, changes name of all transport modes in the tibble copy to united_name = "united" that matches PATTERNS given in unite.columns} + +\item{united.name}{if columns were united, you can specify name for the resulting column in plot} + +\item{dump.output.to}{path to a folder to save csv file of ODMatrix} + +\item{only.files}{boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly} + +\item{tripsTable1}{tibble of trips_output (from \link{read_output_trips},f.e. base case)} + +\item{tripsTable2}{tibble of trips_output (from \link{read_output_trips},f.e. policy case)} + +\item{shapeTable}{sf object(data.frame with geometries), can be received by using st_read(path_to_geographical_file)} + +\item{crs}{numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation} + +\item{show.onlyChanges}{boolean, if it is set to TRUE => sankey diagram only contains changes on axes} + +\item{table}{tibble of trips_output (from \link{read_output_trips})} + +\item{start.inshape}{bool, defines trips to conclude (see Description)} + +\item{end.inshape}{bool, defines trips to conclude (see Description)} + +\item{optimized}{bool, by default FALSE and gives interactive plot using leaflet, if TRUE using image with ggplot} + +\item{baseFolder}{specifies data source folder with multiple base output_trips} + +\item{policyFolder}{specifies data source folder with multiple policy output_trips} + +\item{shapeFilePath}{specifies shapeFile used for comparison} + +\item{shapePath}{full path to shapefile (if simwrapper TRUE, folder with shapeFile should contain also .dbf with the same name)} + +\item{simwrapper}{create output in a simwrapper form if set to path of the shapefile} + +\item{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} + +\item{outer}{logical that represent if the table should contain outside flow of the shape, it isn't} + +\item{folder}{specifies path to find config} + +\item{geometry.type}{function of sf transformation, geometry.type can be (by default is st_multipoint())\cr +!!!st_point()-resulting table contains 2 geometries start_wkt and end_wkt, representing start and end POINTs, and have type POINT!!! or \cr +!!!st_multipoint()-resulting table contains 1 geometry wkt, representing start and end POINTS as MULTIPOINT!!! or \cr +!!!st_linestring() - resulting table contains 1 geometry wkt, representing line between start and end points as LINESTRING!!!} +} +\value{ +\strong{loadNetwork} - "nodes" and "links" tibbles in a list object. + +\strong{readPersonsTable} - tibble of output_persons + +\strong{boxplotScoreDifferences} - ggplot boxplot of the distribution of the score differences + +\strong{plotModalSplitPieChart} - Pie Chart plot of transport mode distribution, values given in percents + +\strong{plotModalSplitBarChart} - Bar Chart plot of transport mode distribution, values given in percents + +\strong{readTripsTable} - tibble of output_trips + +\strong{plotAverageTravelWait} - Bar Chart plot of average time spent on travel/wait + +\strong{plotModalDistanceDistribution} Bar Chart plot of count of trips among distance travelled + +\strong{compareModalDistanceDistribution} - Bar Chart plot of count of trips among distance travelled + +\strong{plotTripDistanceByMode} - Bar Chart plot of distance traveled per mode + +\strong{plotTripCountByDepTime} - Line Chart plot of trips count by departure mode per mode + +\strong{plotActivityEndTimes} Line plot with departure time x-axis and number start activities on y-axis + +\strong{plotArrivalTimesPerTripPurpose} - Line plot with arrival time x-axis and number end activities on y-axis + +\strong{plotDepartureTimesPerTripPurpose} - Line plot with arrival time x-axis and number end activities on y-axis + +\strong{plotTripDistancedByType} - Bar Chart plot of distance traveled by type + +\strong{plotModalShiftSankey} - Alluvial diagram that represents changes in transport mode distribution of trip tables + +\strong{plotModalShiftBar} - plots Bar Chart of transport mode changes with additional files for simwrapper + +\strong{plotMapWithFilteredTrips} - plot with trips filtered depending on flags *.inshape on map from shapeTable + +\strong{plotMapWithTrips} - plot with trips + +\strong{plotTripTypesPieChart} - plot with percentage of each type of trips + +\strong{compareTripTypesBarChart} - plot with percentage of each type of trips between 2 tables + +\strong{plotMapWithTripsType} - plot that contains every trip with defined trip type + +\strong{compareBasePolicyOutput} - list of tibbles, list of all base and policy output_trips as tibble + +\strong{compareBasePolicyShapeOutput} - list of tibbles, list of all base and policy output_trips as tibble + +tibble of output_trips with distance category column + +\strong{filterByRegion} - tibble, with filtered trips depending on shapeTable and special flags (see Description) + +\strong{deriveODMatrix} - tibble of origin/destination matrix + +\strong{getCrsFromConfig} - code of coordinate reference system + +\strong{transformToSf} - sf object (data.frame with geometries depending to geometry.type) +} +\description{ +\strong{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.\cr +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. + +\strong{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 + +\strong{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.\cr\cr +\strong{plotModalSplitPieChart} - Takes Table trips_output (from \link{read_output_trips}), +to plot pie chart with with values that represent +percentage of using transport modes from trips + +\strong{plotModalSplitBarChart} - Takes Table trips_output (from \link{read_output_trips}), +to plot bar chart with with values that represent +percentage of using transport modes from trips + +\strong{readTripsTable} - Loads a MATSim output_trips file from file or archive path, +creating a tibble + +\strong{plotAverageTravelWait} - Takes Table trips_output (from \link{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') + +\strong{plotModalDistanceDistribution} - Takes Table trips_output (from \link{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') + +\strong{compareModalDistanceDistribution} - Takes 2 Tables trips_output (from \link{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') + +\strong{plotTripDistanceByMode} - Takes Table trips_output (from \link{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') + +\strong{plotTripCountByDepTime} - Takes Table trips_output (from \link{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') + +\strong{plotActivityEndTimes} - Takes Table trips_output (from \link{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') + +\strong{plotArrivalTimesPerTripPurpose} - Takes Table trips_output (from \link{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') + +\strong{plotDepartureTimesPerTripPurpose} - Takes Table trips_output (from \link{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') + +\strong{plotTripDistancedByType} - Takes Table trips_output (from \link{read_output_trips}), +to plot bar chart with with values that represent +travelled distance of each tripType related to the shapeTable + +\strong{plotModalShiftSankey} - Takes two trips_table (from \link{read_output_trips}), and collects +changes between transport mode distribution of these tables +to make alluvial diagram from this data\cr +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 + +\strong{plotModalShiftBar} - Takes two trips_table (from \link{read_output_trips}), and collects +changes between transport mode distribution of these tables +to make bar chart diagram with dodging positioning from this data\cr +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 + +\strong{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:\cr +if start.inshape = TRUE & end.inshape = TRUE return table that contains trips inside given shape +\cr if start.inshape = TRUE & end.inshape = FALSE return table that contains trips which starts in shape and ends out of the shape +\cr if start.inshape = FALSE & end.inshape = TRUE return table that contains trips which ends in shape and starts out of the shape +\cr if start.inshape = FALSE & end.inshape = FALSE return table that contains trips which starts and ends our of the given shape +\cr result of filtering is plotted on map of shapeTable where green points are startpoints of trip and red points are endpoints of trip + +\strong{plotMapWithTrips} - Plots start and end coordinates of the given trips table on an osm map + +\strong{plotTripTypesPieChart} - plots distribution of every type of trips(inside, outside, origin and destinating) in Pie Chart + +\strong{compareTripTypesBarChart} - Creates BarChart of changing trip types(originating,transit etc) between 2 tables +and saves output to dump.output.to + +\strong{plotMapWithTripsType} - plots every type of trips(inside, outside, origin and destinating) on map + +\strong{compareBasePolicyOutput} - Chooses a function to compare output_trips from the folders. +baseFolder contains all base outputs, policyFolder contains all policy outputs. + +\strong{compareBasePolicyShapeOutput} - Chooses a function to compare output_trips from the folders. +baseFolder contains all base outputs, policyFolder contains all policy outputs. + +\strong{appendDistanceCategory} - adds to trips output tibble additional column that represent distance as category + +\strong{filterByRegion} - Filtering of trips_table(from \link{read_output_trips}) depending on how they located in given shape\cr +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: \cr +if start.inshape = TRUE & end.inshape = TRUE return table that contains trips inside given shape\cr +if start.inshape = TRUE & end.inshape = FALSE return table that contains trips which starts in shape and ends out of the shape\cr +if start.inshape = FALSE & end.inshape = TRUE return table that contains trips which ends in shape and starts out of the shape\cr +if start.inshape = FALSE & end.inshape = FALSE return table that contains trips which starts and ends our of the given shape + +\strong{deriveODMatrix} - Creates an instance of ODMatrix(origin/destination) in conventional form or for the simwrapper + +\strong{getCrsFromConfig} - Reads an coordinate reference system of MATSim output directory +from output_config.xml + +\strong{transformToSf} - Transforms trips_table tibble (from \link{read_output_trips}) from tibble to sf (table with attribute features and geometry feature)\cr +Takes trips_table (from \link{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.\cr +And adds wkt column, if geometry.type = st_mulitpoint(), or geometry.type = st_linestring()\cr +Or adds start_wkt and end_wkt, if geometry.type = st_point()\cr +Added column/columns projected to given CRS (coordinate reference system), +that can be taken from network file of MATSimOutputDirectory\cr +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 +} +\section{Details}{ + + \code{plotModalSplitPieChart} now a synonym for \code{\link{plot_mainmode_piechart}}\cr + \code{plotModalSplitBarChart} now a synonym for \code{\link{plot_mainmode_barchart}}\cr + \code{plotAverageTravelWait} now a synonym for \code{\link{plot_travelwaittime_mean_barchart}}\cr + \code{plotModalDistanceDistribution} now a synonym for \code{\link{plot_distcat_by_mainmode_barchart}}\cr + \code{plotTripDistanceByMode} now a synonym for \code{\link{plot_distance_by_mainmode_barchart}}\cr + \code{plotTripCountByDepTime} now a synonym for \code{\link{plot_trips_count_by_deptime_and_mainmode_linechart}}\cr + \code{plotActivityEndTimes} not part of package(contained false logic)\cr + \code{plotArrivalTimesPerTripPurpose}now a synonym for \code{\link{plot_arrtime_by_act}}\cr + \code{plotDepartureTimesPerTripPurpose} now a synonym for \code{\link{plot_deptime_by_act}}\cr + \code{plotTripTypesPieChart} now a synonym for \code{\link{plot_spatialtype_by_shape_piechart}}\cr + \code{plotMapWithFilteredTrips}not part of package, you can filter before drawing a map\cr + \code{plotMapWithTrips}now a synonym for \code{\link{plot_map_trips}}\cr + \code{plotMapWithTripsType} now a synonym for \code{\link{plot_map_trips_by_spatialcat}}\cr + \code{plotTripDistancedByType} now a synonym for \code{\link{plot_distance_by_spatialcat_barchart}}\cr + \code{plotModalShiftBar} now a synonym for \code{\link{plot_compare_mainmode_barchart}}\cr + \code{plotModalShiftSankey} now a synonym for \code{\link{plot_compare_mainmode_sankey}}\cr + \code{compareAverageTravelWait} now a synonym for \code{\link{plot_compare_travelwaittime_by_mainmode_barchart}}\cr + \code{compareTripTypesBarChart}now a synonym for \code{\link{plot_compare_count_by_spatialcat_barchart}}\cr + \code{compareModalDistanceDistribution} now a synonym for \code{\link{plot_compare_distcat_by_mainmode_barchart}}\cr + \code{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 \strong{soboliev@campus.tu-berlin.de}\cr + \code{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 \strong{soboliev@campus.tu-berlin.de}\cr + \code{appendDistanceCategory}now a synonym for \code{\link{process_append_distcat}}\cr + \code{filterByRegion} now a synonym for \code{\link{process_filter_by_shape}}\cr + \code{deriveODMatrix} now a synonym for \code{\link{process_get_od_matrix}}\cr + \code{getCrsFromConfig}now a synonym for \code{\link{process_get_crs_from_config}}\cr + \code{transformToSf} now a synonym for \code{\link{process_convert_table_to_sf}}\cr + \code{readTripsTable}now a synonym for \code{\link{read_output_trips}}\cr + \code{readConfig} now a synonym for \code{\link{read_config}}\cr +} + diff --git a/man/mergeCountsAndLinks.Rd b/man/mergeCountsAndLinks.Rd index eb84435..f9cd926 100644 --- a/man/mergeCountsAndLinks.Rd +++ b/man/mergeCountsAndLinks.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/counts.R \name{mergeCountsAndLinks} \alias{mergeCountsAndLinks} -\title{Load Counts, a limited number of Linkstats and Network links as joined tibble into memory} +\title{Join counts and linkstats to the network, creating a tibble into memory} \usage{ mergeCountsAndLinks( counts, @@ -19,20 +19,20 @@ mergeCountsAndLinks( \item{network}{Tibble with network nodes and links} -\item{linkStats}{List with link stats tibbles} +\item{linkStats}{List with linkstats tibbles} -\item{networkModes}{a vector with network modes, which are needed for analysis} +\item{networkModes}{Vector with network modes that will be analyzed, default is "car".} -\item{aggr_to}{Determinates if data should be aggregated to hour values or DTV, can either be "day" or "hour"} +\item{aggr_to}{Determines if data should be aggregated into hourly bins or as daily traffic volume, can either be "day" or "hour"} -\item{earliest}{Lower limit to filter link stats by time, default is 0} +\item{earliest}{Integer. Lower limit to filter link stats by time, default = 0.} -\item{latest}{Upper limit to filter link stats by time, default is 86400 (midnight)} +\item{latest}{Integer. Upper limit to filter link stats by time, default = 86400 (midnight).} } \value{ -Long-format tibble with MATSim link id as key ("loc_id"), traffic volume from MATSim runs and link type +Long-format tibble with MATSim link id as key ("loc_id"), traffic volumes from MATSim runs and link type } \description{ -Function to join counts, network links and several matsim link stats. Data can be aggregated -and filtered by time or network mode. +Function to join counts, linkstats and network links. Data can be aggregated +and filtered by time or mode. } diff --git a/man/plotActivityEndTimes.Rd b/man/plotActivityEndTimes.Rd deleted file mode 100644 index 3cc8a26..0000000 --- a/man/plotActivityEndTimes.Rd +++ /dev/null @@ -1,35 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{plotActivityEndTimes} -\alias{plotActivityEndTimes} -\title{Line plot that shows the number of activities ending at a given time, per activity type. -The activity end time is derived from the departure time in the given trips tibble.} -\usage{ -plotActivityEndTimes( - tripsTable, - unite.columns = character(0), - united.name = "united", - dump.output.to = matsimDumpOutputDirectory, - only.files = FALSE -) -} -\arguments{ -\item{tripsTable}{tible of trips_output (from readTripsTable())} - -\item{unite.columns}{vector of character strings, that represent patterns of columns to be united, changes name of all activity types in the tibble copy to united.name = "united" that matches PATTERNS given in unite.columns} - -\item{united.name}{character string, if columns were united, you can specify name for the resulting column in chart} - -\item{dump.output.to}{folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored} - -\item{only.files}{boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly} -} -\value{ -Line plot with departure time x-axis and number start activities on y-axis -} -\description{ -Takes Table trips_output (from readTripsTable()), -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') -} diff --git a/man/plotArrivalTimesPerTripPurpose.Rd b/man/plotArrivalTimesPerTripPurpose.Rd deleted file mode 100644 index 773b1e9..0000000 --- a/man/plotArrivalTimesPerTripPurpose.Rd +++ /dev/null @@ -1,35 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{plotArrivalTimesPerTripPurpose} -\alias{plotArrivalTimesPerTripPurpose} -\title{This function plots the number of trips ending per trip purpose over time. The trip purpose corresponds to the activity type of the destination activity of a given trip. -Thus, the y-axis of the plot can also be interpreted as the number of activities starting (based on the assumption that trip end time = activity start time).} -\usage{ -plotArrivalTimesPerTripPurpose( - tripsTable, - unite.columns = character(0), - united.name = "united", - dump.output.to = matsimDumpOutputDirectory, - only.files = FALSE -) -} -\arguments{ -\item{tripsTable}{tibble of trips_output (from readTripsTable())} - -\item{unite.columns}{vector of character strings, that represent patterns of columns to be united, changes name of all activity types in the tibble copy to united.name = "united" that matches PATTERNS given in unite.columns} - -\item{united.name}{character string, if columns were united, you can specify name for the resulting column in plot} - -\item{dump.output.to}{folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored} - -\item{only.files}{boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly} -} -\value{ -Line plot with arrival time x-axis and number end activities on y-axis -} -\description{ -Takes Table trips_output (from readTripsTable()), -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') -} diff --git a/man/plotAverageTravelWait.Rd b/man/plotAverageTravelWait.Rd deleted file mode 100644 index 1f801fb..0000000 --- a/man/plotAverageTravelWait.Rd +++ /dev/null @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{plotAverageTravelWait} -\alias{plotAverageTravelWait} -\title{Bar Chart with main_mode on x-axis and average travel/wait time on y-axis} -\usage{ -plotAverageTravelWait( - tripsTable, - unite.columns = character(0), - united.name = "united", - dump.output.to = matsimDumpOutputDirectory, - only.files = FALSE -) -} -\arguments{ -\item{tripsTable}{tible of trips_output (from readTripsTable())} - -\item{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} - -\item{united.name}{character string, if columns were united, you can specify name for the resulting column in chart} - -\item{dump.output.to}{folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored} - -\item{only.files}{boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly} -} -\value{ -Bar Chart plot of average time spent on travel/wait -} -\description{ -Takes Table trips_output (from readTripsTable()), -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') -} diff --git a/man/plotDepartureTimesPerTripPurpose.Rd b/man/plotDepartureTimesPerTripPurpose.Rd deleted file mode 100644 index 10f1c8b..0000000 --- a/man/plotDepartureTimesPerTripPurpose.Rd +++ /dev/null @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{plotDepartureTimesPerTripPurpose} -\alias{plotDepartureTimesPerTripPurpose} -\title{This function plots the number of trips starting per trip purpose over time. The trip purpose corresponds to the activity type of the destination activity of a given trip.} -\usage{ -plotDepartureTimesPerTripPurpose( - tripsTable, - unite.columns = character(0), - united.name = "united", - dump.output.to = matsimDumpOutputDirectory, - only.files = FALSE -) -} -\arguments{ -\item{tripsTable}{tibble of trips_output (from readTripsTable())} - -\item{unite.columns}{vector of character strings, that represent patterns of columns to be united, changes name of all activity types in the tibble copy to united.name = "united" that matches PATTERNS given in unite.columns} - -\item{united.name}{character string, if columns were united, you can specify name for the resulting column in plot} - -\item{dump.output.to}{folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored} - -\item{only.files}{boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly} -} -\value{ -Line plot with arrival time x-axis and number end activities on y-axis -} -\description{ -Takes Table trips_output (from readTripsTable()), -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') -} diff --git a/man/plotMapWithFilteredTrips.Rd b/man/plotMapWithFilteredTrips.Rd deleted file mode 100644 index 7994067..0000000 --- a/man/plotMapWithFilteredTrips.Rd +++ /dev/null @@ -1,41 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{plotMapWithFilteredTrips} -\alias{plotMapWithFilteredTrips} -\title{Plots result of filtered trips on the map (from shape)} -\usage{ -plotMapWithFilteredTrips( - table, - shapeTable, - crs, - start.inshape = TRUE, - end.inshape = TRUE, - optimized = FALSE -) -} -\arguments{ -\item{table}{tibble of trips_output (from readTripsTable())} - -\item{shapeTable}{sf object(data.frame with geometries), can be received by using st_read(path_to_geographical_file)} - -\item{crs}{numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation} - -\item{start.inshape}{bool, defines trips to conclude (see Description)} - -\item{end.inshape}{bool, defines trips to conclude (see Description)} - -\item{optimized}{bool, by default FALSE and gives interactive plot using leaflet, if TRUE using image with ggplot} -} -\value{ -plot with trips filtered depending on flags *.inshape on map from shapeTable -} -\description{ -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 -} diff --git a/man/plotMapWithTripsType.Rd b/man/plotMapWithTripsType.Rd deleted file mode 100644 index a6cdc0f..0000000 --- a/man/plotMapWithTripsType.Rd +++ /dev/null @@ -1,23 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{plotMapWithTripsType} -\alias{plotMapWithTripsType} -\title{Plots every type of trips(inside, outside, origin and destinating) on map} -\usage{ -plotMapWithTripsType(table, shapeTable, crs, optimized = FALSE) -} -\arguments{ -\item{table}{tibble of trips_output (from readTripsTable())} - -\item{shapeTable}{sf object(data.frame with geometries), can be received by using st_read(path_to_geographical_file)} - -\item{crs}{numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation} - -\item{optimized}{bool, by default FALSE and gives interactive plot using leaflet, if TRUE using image with ggplot} -} -\value{ -plot that contains every trip with defined trip type -} -\description{ -Plots every type of trips(inside, outside, origin and destinating) on map -} diff --git a/man/plotModalDistanceDistribution.Rd b/man/plotModalDistanceDistribution.Rd deleted file mode 100644 index 9f8d21a..0000000 --- a/man/plotModalDistanceDistribution.Rd +++ /dev/null @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{plotModalDistanceDistribution} -\alias{plotModalDistanceDistribution} -\title{Bar Chart with distance travelled on x-axis and number of trips on y-axis} -\usage{ -plotModalDistanceDistribution( - tripsTable, - unite.columns = character(0), - united.name = "united", - dump.output.to = matsimDumpOutputDirectory, - only.files = FALSE -) -} -\arguments{ -\item{tripsTable}{tible of trips_output (from readTripsTable())} - -\item{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} - -\item{united.name}{character string, if columns were united, you can specify name for the resulting column in chart} - -\item{dump.output.to}{folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored} - -\item{only.files}{boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly} -} -\value{ -Bar Chart plot of count of trips among distance travelled -} -\description{ -Takes Table trips_output (from readTripsTable()), -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') -} diff --git a/man/plotModalShiftBar.Rd b/man/plotModalShiftBar.Rd deleted file mode 100644 index 34d6ffe..0000000 --- a/man/plotModalShiftBar.Rd +++ /dev/null @@ -1,41 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{plotModalShiftBar} -\alias{plotModalShiftBar} -\title{Plot bar chart diagram of transport mode changes} -\usage{ -plotModalShiftBar( - tripsTable1, - tripsTable2, - unite.columns = character(0), - united.name = "united", - dump.output.to = matsimDumpOutputDirectory, - output.name = "modalShiftBarChart" -) -} -\arguments{ -\item{tripsTable1}{tible of trips_output (from readTripsTable())} - -\item{tripsTable2}{tible of trips_output (from readTripsTable())} - -\item{unite.columns}{vector of character string, changes name of all transport modes in the tibble copy to united.name = "united" that matches PATTERNS given in unite.columns} - -\item{united.name}{if columns were united, you can specify name for the resulting column in plot} - -\item{dump.output.to}{folder that saves and configures yaml for simwrapper. folder where png of plot is stored} -} -\value{ -plots Bar Chart of transport mode changes with additional files for simwrapper -} -\description{ -Takes two trips_table (from readTripsTable), and collects -changes between transport mode distribution of these tables -to make bar chart diagram with dodging positioning from this data -} -\details{ -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 -} diff --git a/man/plotModalShiftSankey.Rd b/man/plotModalShiftSankey.Rd deleted file mode 100644 index 92534de..0000000 --- a/man/plotModalShiftSankey.Rd +++ /dev/null @@ -1,43 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{plotModalShiftSankey} -\alias{plotModalShiftSankey} -\title{Plot alluvial/sankey diagram of transport mode changes} -\usage{ -plotModalShiftSankey( - tripsTable1, - tripsTable2, - show.onlyChanges = FALSE, - unite.columns = character(0), - united.name = "united", - dump.output.to = matsimDumpOutputDirectory -) -} -\arguments{ -\item{tripsTable1}{tible of trips_output (from readTripsTable())} - -\item{tripsTable2}{tible of trips_output (from readTripsTable())} - -\item{show.onlyChanges}{boolean, if it is set to TRUE => sankey diagram only contains changes on axes} - -\item{unite.columns}{vector of character string, changes name of all transport modes in the tibble copy to united.name = "united" that matches PATTERNS given in unite.columns} - -\item{united.name}{if columns were united, you can specify name for the resulting column in plot} - -\item{dump.output.to}{folder that saves and configures yaml for simwrapper. folder where png of plot is stored} -} -\value{ -Alluvial diagram that represents changes in transport mode distribution of trip tables -} -\description{ -Takes two trips_table (from readTripsTable), and collects -changes between transport mode distribution of these tables -to make alluvial diagram from this data -} -\details{ -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 -} diff --git a/man/plotModalSplitBarChart.Rd b/man/plotModalSplitBarChart.Rd deleted file mode 100644 index ce948f3..0000000 --- a/man/plotModalSplitBarChart.Rd +++ /dev/null @@ -1,38 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{plotModalSplitBarChart} -\alias{plotModalSplitBarChart} -\title{Plot main_mode distribution as a bar Chart} -\usage{ -plotModalSplitBarChart( - tripsTable, - unite.columns = character(0), - united.name = "united", - dump.output.to = matsimDumpOutputDirectory, - only.files = FALSE -) -} -\arguments{ -\item{tripsTable}{tible of trips_output (from readTripsTable())} - -\item{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} - -\item{united.name}{character string, if columns were united, you can specify name for the resulting column in chart} - -\item{dump.output.to}{folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored} - -\item{only.files}{boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly} -} -\value{ -Bar Chart plot of transport mode distribution, values given in percents -} -\description{ -Takes Table trips_output (from readTripsTable()), -to plot bar chart with with values that represent -percentage of using transport modes from trips -} -\details{ -Function automatically detects transport_modes from table -and plots pie chart with percentage of distribution. -Using parameters unite.columns, specific columns could be given, to unite them in 1 mode with the name united.name(by default 'united') -} diff --git a/man/plotModalSplitPieChart.Rd b/man/plotModalSplitPieChart.Rd deleted file mode 100644 index ebd48b1..0000000 --- a/man/plotModalSplitPieChart.Rd +++ /dev/null @@ -1,38 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{plotModalSplitPieChart} -\alias{plotModalSplitPieChart} -\title{Plot main_mode distribution as a Pie Chart} -\usage{ -plotModalSplitPieChart( - tripsTable, - unite.columns = character(0), - united.name = "united", - dump.output.to = matsimDumpOutputDirectory, - only.files = FALSE -) -} -\arguments{ -\item{tripsTable}{tible of trips_output (from readTripsTable())} - -\item{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} - -\item{united.name}{character string, if columns were united, you can specify name for the resulting column in chart} - -\item{dump.output.to}{folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored} - -\item{only.files}{boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly} -} -\value{ -Pie Chart plot of transport mode distribution, values given in percents -} -\description{ -Takes Table trips_output (from readTripsTable()), -to plot pie chart with with values that represent -percentage of using transport modes from trips -} -\details{ -Function automatically detects transport_modes from table -and plots pie chart. -Using parameters unite.columns, specific columns could be given, to unite them in 1 mode with the name united.name(by default 'united') -} diff --git a/man/plotTripCountByDepTime.Rd b/man/plotTripCountByDepTime.Rd deleted file mode 100644 index dce7c72..0000000 --- a/man/plotTripCountByDepTime.Rd +++ /dev/null @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{plotTripCountByDepTime} -\alias{plotTripCountByDepTime} -\title{Line plot with departure time x-axis and number of trips on y-axis} -\usage{ -plotTripCountByDepTime( - tripsTable, - unite.columns = character(0), - united.name = "united", - dump.output.to = matsimDumpOutputDirectory, - only.files = FALSE -) -} -\arguments{ -\item{tripsTable}{tible of trips_output (from readTripsTable())} - -\item{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} - -\item{united.name}{character string, if columns were united, you can specify name for the resulting column in chart} - -\item{dump.output.to}{folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored} - -\item{only.files}{boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly} -} -\value{ -Line Chart plot of trips count by departure mode per mode -} -\description{ -Takes Table trips_output (from readTripsTable()), -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') -} diff --git a/man/plotTripDistanceByMode.Rd b/man/plotTripDistanceByMode.Rd deleted file mode 100644 index 5dc6863..0000000 --- a/man/plotTripDistanceByMode.Rd +++ /dev/null @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{plotTripDistanceByMode} -\alias{plotTripDistanceByMode} -\title{Bar Chart with distance travelled on x-axis and number of trips on y-axis} -\usage{ -plotTripDistanceByMode( - tripsTable, - unite.columns = character(0), - united.name = "united", - dump.output.to = matsimDumpOutputDirectory, - only.files = FALSE -) -} -\arguments{ -\item{tripsTable}{tible of trips_output (from readTripsTable())} - -\item{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} - -\item{united.name}{character string, if columns were united, you can specify name for the resulting column in chart} - -\item{dump.output.to}{folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored} - -\item{only.files}{boolean, that represent if plotting inside project is needed, by default FALSE - means function gives out a plot by plot_ly} -} -\value{ -Bar Chart plot of distance traveled per mode -} -\description{ -Takes Table trips_output (from readTripsTable()), -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') -} diff --git a/man/plotTripDistancedByType.Rd b/man/plotTripDistancedByType.Rd deleted file mode 100644 index 4225d61..0000000 --- a/man/plotTripDistancedByType.Rd +++ /dev/null @@ -1,30 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{plotTripDistancedByType} -\alias{plotTripDistancedByType} -\title{Bar Chart with tripType on x-axis and travelled distance on y-axis} -\usage{ -plotTripDistancedByType( - tripsTable, - shapeTable, - crs, - dump.output.to = matsimDumpOutputDirectory -) -} -\arguments{ -\item{tripsTable}{tible of trips_output (from readTripsTable())} - -\item{shapeTable}{sf object(data.frame with geometries), can be received by using st_read(path_to_geographical_file)} - -\item{crs}{numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation} - -\item{dump.output.to}{folder that saves and configures yaml for simwrapper dashboard. folder where png of plot is stored} -} -\value{ -Bar Chart plot of distance traveled by type -} -\description{ -Takes Table trips_output (from readTripsTable()), -to plot bar chart with with values that represent -travelled distance of each tripType related to the shapeTable -} diff --git a/man/plotTripTypesPieChart.Rd b/man/plotTripTypesPieChart.Rd deleted file mode 100644 index 23368ae..0000000 --- a/man/plotTripTypesPieChart.Rd +++ /dev/null @@ -1,21 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{plotTripTypesPieChart} -\alias{plotTripTypesPieChart} -\title{Plots distribution of every type of trips(inside, outside, origin and destinating) in Pie Chart} -\usage{ -plotTripTypesPieChart(table, shapeTable, crs) -} -\arguments{ -\item{table}{tibble of trips_output (from readTripsTable())} - -\item{shapeTable}{sf object(data.frame with geometries), can be received by using st_read(path_to_geographical_file)} - -\item{crs}{numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation} -} -\value{ -plot with percentage of each type of trips -} -\description{ -Plots distribution of every type of trips(inside, outside, origin and destinating) in Pie Chart -} diff --git a/man/plot_arrtime_by_act.Rd b/man/plot_arrtime_by_act.Rd new file mode 100644 index 0000000..bbc54de --- /dev/null +++ b/man/plot_arrtime_by_act.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{plot_arrtime_by_act} +\alias{plot_arrtime_by_act} +\title{Plot Arrival Time by Activity} +\usage{ +plot_arrtime_by_act( + trips_table, + unite_activities = character(0), + united_name = "united" +) +} +\arguments{ +\item{trips_table}{tibble of trips_output (from \link{read_output_trips})} + +\item{unite_activities}{vector of character strings, that represent patterns of columns to be united, changes name of all activity types in the tibble copy to united_name = "united" that matches PATTERNS given in unite.columns} + +\item{united_name}{character string, if columns were united, you can specify name for the resulting column in plot} +} +\value{ +A plotly object representing the line plot of arrival time by activity. +} +\description{ +\strong{plot_arrtime_by_act} - Takes Table trips_output (from \link{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') +} diff --git a/man/plot_compare_count_by_spatialcat_barchart.Rd b/man/plot_compare_count_by_spatialcat_barchart.Rd new file mode 100644 index 0000000..ab6e7a5 --- /dev/null +++ b/man/plot_compare_count_by_spatialcat_barchart.Rd @@ -0,0 +1,32 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{plot_compare_count_by_spatialcat_barchart} +\alias{plot_compare_count_by_spatialcat_barchart} +\title{Plot Comparison of Count by Spatial Category (Bar Chart)} +\usage{ +plot_compare_count_by_spatialcat_barchart( + trips_table1, + trips_table2, + shape_table, + crs +) +} +\arguments{ +\item{trips_table1}{tible of trips_output (from \link{read_output_trips})} + +\item{trips_table2}{tible of trips_output (from \link{read_output_trips})} + +\item{shape_table}{A spatial shapefile or spatial polygons data frame used to create the spatial categories.} + +\item{crs}{numeric representation of the EPSG code or proj4string for the corresponding coordinate system of the trip coordinates, +can be found in network file from output directory of MATSim simulation} +} +\value{ +A plotly object representing the bar chart of the comparison of count by spatial category. +} +\description{ +The \code{plot_compare_count_by_spatialcat_barchart} +function generates a bar chart to compare the count of trips between two trips_table +tibbles across different spatial categories. +It provides insights into the distribution of trips across spatial categories for each table. +} diff --git a/man/plot_compare_distcat_by_mainmode_barchart.Rd b/man/plot_compare_distcat_by_mainmode_barchart.Rd new file mode 100644 index 0000000..a2d1b3a --- /dev/null +++ b/man/plot_compare_distcat_by_mainmode_barchart.Rd @@ -0,0 +1,42 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{plot_compare_distcat_by_mainmode_barchart} +\alias{plot_compare_distcat_by_mainmode_barchart} +\title{Bar chart comparing distance traveled on x-axis and number of trips on y-axis for two different runs +Takes two data frames (from \link{read_output_trips}), categorizes the traveled distances into pre-defined bins +and plots the difference in number of trips for each bin. (Bins: 1000,2000,5000,10000,20000,50000,100000 (m)) +Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united')} +\usage{ +plot_compare_distcat_by_mainmode_barchart( + trips_table1, + trips_table2, + unite_modes = character(0), + united_name = "united", + dist_column = "dist_cat", + distances_array = c(1000, 2000, 5000, 10000, 20000, 50000, 1e+05) +) +} +\arguments{ +\item{trips_table1}{tibble of trips_output (from \link{read_output_trips}), number of trips of this table will be extracted from number of trips of tripsTable1} + +\item{trips_table2}{tibble of trips_output (from \link{read_output_trips}), from number of trips of this table number of trips of tripsTable1 will be extracted} + +\item{unite_modes}{vector of character strings, +changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +using the function (\link{process_rename_mainmodes})} + +\item{united_name}{character string, specifies the name of the united mode} + +\item{dist_column}{A character string specifying the column name in the trips_table tibble that contains the distance categories.} + +\item{distances_array}{A numeric vector defining the distance thresholds for creating distance categories.} +} +\value{ +Bar Chart plot of count of trips among distance travelled +} +\description{ +Bar chart comparing distance traveled on x-axis and number of trips on y-axis for two different runs +Takes two data frames (from \link{read_output_trips}), categorizes the traveled distances into pre-defined bins +and plots the difference in number of trips for each bin. (Bins: 1000,2000,5000,10000,20000,50000,100000 (m)) +Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') +} diff --git a/man/plot_compare_mainmode_barchart.Rd b/man/plot_compare_mainmode_barchart.Rd new file mode 100644 index 0000000..a1829cc --- /dev/null +++ b/man/plot_compare_mainmode_barchart.Rd @@ -0,0 +1,32 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{plot_compare_mainmode_barchart} +\alias{plot_compare_mainmode_barchart} +\title{Plot bar chart of changes in modal split} +\usage{ +plot_compare_mainmode_barchart( + trips_table1, + trips_table2, + unite_modes = character(0), + united_name = "united" +) +} +\arguments{ +\item{trips_table1}{tibble of trips_output (from \link{read_output_trips})} + +\item{trips_table2}{tibble of trips_output (from \link{read_output_trips})} + +\item{unite_modes}{vector of character strings, +changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +using the function (\link{process_rename_mainmodes})} + +\item{united_name}{character string, specifies the name of the united mode} +} +\value{ +plots bar chart of changes in modal split +} +\description{ +Takes two data frames (from \link{read_output_trips}), calculates the +changes in mode shares and plots them as a bar chart +Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') +} diff --git a/man/plot_compare_mainmode_sankey.Rd b/man/plot_compare_mainmode_sankey.Rd new file mode 100644 index 0000000..dd7ccf2 --- /dev/null +++ b/man/plot_compare_mainmode_sankey.Rd @@ -0,0 +1,35 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{plot_compare_mainmode_sankey} +\alias{plot_compare_mainmode_sankey} +\title{Plot alluvial/sankey diagram of transport mode changes} +\usage{ +plot_compare_mainmode_sankey( + trips_table1, + trips_table2, + show_onlychanges = FALSE, + unite_modes = character(0), + united_name = "united" +) +} +\arguments{ +\item{trips_table1}{tibble of trips_output (from read_output_trips())} + +\item{trips_table2}{tibble of trips_output (from read_output_trips())} + +\item{show_onlychanges}{boolean, if it is set to TRUE the sankey diagram only shows the mode shift} + +\item{unite_modes}{vector of character strings, +changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +using the function (\link{process_rename_mainmodes})} + +\item{united_name}{character string, specifies the name of the united mode} +} +\value{ +Alluvial diagram that represents changes in transport mode distribution +} +\description{ +Takes two data frames (from \link{read_output_trips}) and compares the mode choice for each agent and summarizes the results, showing the modal shift. +Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') +The parameter show.onlyChanges allows the visualization of only the mode shift (excluding the trips that do not change mode). Standard value is FALSE. +} diff --git a/man/plot_compare_score_boxplot.Rd b/man/plot_compare_score_boxplot.Rd new file mode 100644 index 0000000..f11652c --- /dev/null +++ b/man/plot_compare_score_boxplot.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_persons.R +\name{plot_compare_score_boxplot} +\alias{plot_compare_score_boxplot} +\title{Boxplot of Score Differences} +\usage{ +plot_compare_score_boxplot(personTibble_base, personTibble_policy) +} +\arguments{ +\item{personTibble_base}{persons tibble of the base case, can be loaded with readPersonsTable.} + +\item{personTibble_policy}{persons tibble of the policy case, can be loaded with readPersonsTable.} +} +\value{ +ggplot boxplot of the distribution of the score differences +} +\description{ +The \code{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. +} diff --git a/man/plot_compare_travelwaittime_by_mainmode.Rd b/man/plot_compare_travelwaittime_by_mainmode.Rd new file mode 100644 index 0000000..06d5048 --- /dev/null +++ b/man/plot_compare_travelwaittime_by_mainmode.Rd @@ -0,0 +1,35 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{plot_compare_travelwaittime_by_mainmode} +\alias{plot_compare_travelwaittime_by_mainmode} +\title{Bar Chart comparing two runs with main_mode on x-axis and average travel/wait time on y-axis} +\usage{ +plot_compare_travelwaittime_by_mainmode( + trips_table1, + trips_table2, + unite_modes = character(0), + united_name = "united", + time_format = "minute" +) +} +\arguments{ +\item{trips_table1}{tibble of trips_output (from \link{read_output_trips})} + +\item{trips_table2}{tibble of trips_output (from \link{read_output_trips})} + +\item{unite_modes}{vector of character strings, +changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +using the function (\link{process_rename_mainmodes})} + +\item{united_name}{character string, specifies the name of the united mode#'} + +\item{time_format}{character string, defines time format to be used(takes "hour", "minute", "second")} +} +\value{ +Bar chart plot comparing average time spent on travel/wait of two runs +} +\description{ +Takes two data frames (from \link{read_output_trips}), +to plot a comparison bar chart of travel and wait times. +Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') +} diff --git a/man/plot_compare_travelwaittime_by_mainmode_barchart.Rd b/man/plot_compare_travelwaittime_by_mainmode_barchart.Rd new file mode 100644 index 0000000..ad4abbf --- /dev/null +++ b/man/plot_compare_travelwaittime_by_mainmode_barchart.Rd @@ -0,0 +1,35 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{plot_compare_travelwaittime_by_mainmode_barchart} +\alias{plot_compare_travelwaittime_by_mainmode_barchart} +\title{Comparison bar chart with main_mode on x-axis and average travel/wait time on y-axis} +\usage{ +plot_compare_travelwaittime_by_mainmode_barchart( + trips_table1, + trips_table2, + unite_modes = character(0), + united_name = "united", + time_format = "minute" +) +} +\arguments{ +\item{trips_table1}{tibble of trips_output (from \link{read_output_trips})} + +\item{trips_table2}{tibble of trips_output (from \link{read_output_trips})} + +\item{unite_modes}{vector of character strings, +changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +using the function (\link{process_rename_mainmodes})} + +\item{united_name}{character string, specifies the name of the united mode} + +\item{time_format}{character string, defines time format to be used(takes "hour", "minute", "second")} +} +\value{ +Bar chart plot of average travel/wait time +} +\description{ +Takes the data frame trips_output (from \link{read_output_trips}), +to plot a bar chart of the traveling/waiting time +Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') +} diff --git a/man/plot_deptime_by_act.Rd b/man/plot_deptime_by_act.Rd new file mode 100644 index 0000000..b96edca --- /dev/null +++ b/man/plot_deptime_by_act.Rd @@ -0,0 +1,26 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{plot_deptime_by_act} +\alias{plot_deptime_by_act} +\title{Plot Departure Time by Activity} +\usage{ +plot_deptime_by_act( + trips_table, + unite_activities = character(0), + united_name = "united" +) +} +\arguments{ +\item{unite_activities}{vector of character strings, that represent patterns of columns to be united, changes name of all activity types in the tibble copy to united_name = "united" that matches PATTERNS given in unite_columns} + +\item{united_name}{character string, if columns were united, you can specify name for the resulting column in plot} + +\item{tripsTable}{tibble of trips_output (from \link{read_output_trips})} +} +\value{ +A plotly object representing the line plot of departure time by activity. +} +\description{ +The \code{plot_deptime_by_act} function generates a line plot to visualize the departure time of trips by activity in a given trips_table tibble. +It provides insights into the number of trips starting at different times for each activity. +} diff --git a/man/plot_distance_by_mainmode_barchart.Rd b/man/plot_distance_by_mainmode_barchart.Rd new file mode 100644 index 0000000..fb9da71 --- /dev/null +++ b/man/plot_distance_by_mainmode_barchart.Rd @@ -0,0 +1,32 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{plot_distance_by_mainmode_barchart} +\alias{plot_distance_by_mainmode_barchart} +\title{Bar chart with average distance traveled for each mode on x-axis and number of trips on y-axis} +\usage{ +plot_distance_by_mainmode_barchart( + trips_table, + unite_modes = character(0), + united_name = "united", + euclidean = FALSE +) +} +\arguments{ +\item{trips_table}{tibble of trips_output (from \link{read_output_trips})} + +\item{unite_modes}{vector of character strings, +changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +using the function (\link{process_rename_mainmodes})} + +\item{united_name}{character string, specifies the name of the united mode} + +\item{euclidean}{Logical value indicating whether to calculate the average as euclidean distance or as travel distance. Default is FALSE, which calculates the average traveled distance.} +} +\value{ +Bar Chart plot of distance traveled per mode +} +\description{ +Takes the data frame trips_output (from \link{read_output_trips}), +to plot a bar chart of the average distance traveled for each main mode, +Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') +} diff --git a/man/plot_distance_by_spatialcat_barchart.Rd b/man/plot_distance_by_spatialcat_barchart.Rd new file mode 100644 index 0000000..8a4204f --- /dev/null +++ b/man/plot_distance_by_spatialcat_barchart.Rd @@ -0,0 +1,30 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{plot_distance_by_spatialcat_barchart} +\alias{plot_distance_by_spatialcat_barchart} +\title{Bar Chart with tripType on x-axis and travelled distance on y-axis} +\usage{ +plot_distance_by_spatialcat_barchart( + trips_table, + shape_table, + crs, + euclidean = FALSE +) +} +\arguments{ +\item{trips_table}{tible of trips_output (from \link{read_output_trips})} + +\item{crs}{numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation} + +\item{euclidean}{Logical value indicating whether to calculate the average as euclidean distance or as travel distance. Default is FALSE, which calculates the average traveled distance.} + +\item{shape_Table}{sf object(data frame with geometries), can be created using st_read(), is used to categorize the trips.} +} +\value{ +Bar Chart plot of distance traveled by spatial type +} +\description{ +Takes Table trips_output (from \link{read_output_trips}), +to plot bar chart with with values that represent +travelled distance of each tripType related to the shapeTable +} diff --git a/man/plot_distcat_by_mainmode_barchart.Rd b/man/plot_distcat_by_mainmode_barchart.Rd new file mode 100644 index 0000000..ebab546 --- /dev/null +++ b/man/plot_distcat_by_mainmode_barchart.Rd @@ -0,0 +1,35 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{plot_distcat_by_mainmode_barchart} +\alias{plot_distcat_by_mainmode_barchart} +\title{Bar Chart with distance traveled on x-axis and number of trips on y-axis} +\usage{ +plot_distcat_by_mainmode_barchart( + trips_table, + unite_modes = character(0), + united_name = "united", + dist_column = "dist_cat", + distances_array = c(1000, 2000, 5000, 10000, 20000, 50000, 1e+05) +) +} +\arguments{ +\item{trips_table}{tibble of trips_output (from \link{read_output_trips})} + +\item{unite_modes}{vector of character strings, +changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +using the function (\link{process_rename_mainmodes})} + +\item{united_name}{character string, specifies the name of the united mode} + +\item{dist_column}{A character string specifying the column name in the trips_table tibble that contains the distance categories.} + +\item{distances_array}{A numeric vector defining the distance thresholds for creating distance categories.} +} +\value{ +Plotly bar Chart of count of trips among distance travelled +} +\description{ +Takes the data frame trips_output (from \link{read_output_trips}) and categorizes the traveled distances into pre-defined bins +to plot a histogram of the traveled distances. (Bins: 1000,2000,5000,10000,20000,50000,100000 (m)) +Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') +} diff --git a/man/plot_mainmode_barchart.Rd b/man/plot_mainmode_barchart.Rd new file mode 100644 index 0000000..8eb43a3 --- /dev/null +++ b/man/plot_mainmode_barchart.Rd @@ -0,0 +1,36 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{plot_mainmode_barchart} +\alias{plot_mainmode_barchart} +\title{Plot the distribution of modes as a bar chart} +\usage{ +plot_mainmode_barchart( + trips_table, + unite_modes = character(0), + united_name = "united", + percentage = FALSE +) +} +\arguments{ +\item{trips_table}{tibble of trips_output (from \link{read_output_trips})} + +\item{unite_modes}{vector of character strings, +changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +using the function (\link{process_rename_mainmodes})} + +\item{united_name}{character string, specifies the name of the united mode} + +\item{percentage}{boolean, by default FALSE, sets if output is given in percentage} +} +\value{ +Bar Chart plot of transport mode distribution, values given in percents +} +\description{ +Takes the data frame trips_output (from \link{read_output_trips}) +to plot a bar chart of the modal split using the column main_mode. +} +\details{ +The modal shares are given in percentages. + +Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') +} diff --git a/man/plot_mainmode_piechart.Rd b/man/plot_mainmode_piechart.Rd new file mode 100644 index 0000000..50b2f92 --- /dev/null +++ b/man/plot_mainmode_piechart.Rd @@ -0,0 +1,32 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{plot_mainmode_piechart} +\alias{plot_mainmode_piechart} +\title{Plot the distribution of modes as a pie chart} +\usage{ +plot_mainmode_piechart( + trips_table, + unite_modes = character(0), + united_name = "united" +) +} +\arguments{ +\item{trips_table}{tibble of trips_output (from \link{read_output_trips})} + +\item{unite_modes}{vector of character strings, +changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +using the function (\link{process_rename_mainmodes})} + +\item{united_name}{character string, specifies the name of the united mode} +} +\value{ +pie chart plot of transport mode distribution, values given in percent +} +\description{ +Uses the dataframe trips_output (from \link{read_output_trips}), +to plot a pie chart of the modal split using the column main_mode +} +\details{ +The function automatically detects the modes plots a pie chart. +Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') +} diff --git a/man/plotMapWithTrips.Rd b/man/plot_map_trips.Rd similarity index 58% rename from man/plotMapWithTrips.Rd rename to man/plot_map_trips.Rd index 5b76b4a..71d0676 100644 --- a/man/plotMapWithTrips.Rd +++ b/man/plot_map_trips.Rd @@ -1,20 +1,22 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{plotMapWithTrips} -\alias{plotMapWithTrips} +% Please edit documentation in R/output_trips.R +\name{plot_map_trips} +\alias{plot_map_trips} \title{Plots start and end coordinates of the given trips table on an osm map} \usage{ -plotMapWithTrips(table, crs, optimized = FALSE) +plot_map_trips(trips_table, crs, optimized = FALSE, shape_table = NULL) } \arguments{ -\item{table}{tibble of trips_output (from readTripsTable())} +\item{trips_table}{tibble of trips_output (from \link{read_output_trips})} \item{crs}{numeric representation of the EPSG code or proj4string for the corresponding coordinate system of the trip coordinates, can be found in network file from output directory of MATSim simulation} \item{optimized}{bool, by default FALSE and gives interactive plot using leaflet, if TRUE using image with ggplot} + +\item{shape_table}{A spatial shapefile or spatial polygons data frame used as a background. By default NULL.} } \value{ -plot with trips +leaflet/ggplot plot with trips start-, end- points } \description{ Plots start and end coordinates of the given trips table on an osm map diff --git a/man/plot_map_trips_by_spatialcat.Rd b/man/plot_map_trips_by_spatialcat.Rd new file mode 100644 index 0000000..d094e0c --- /dev/null +++ b/man/plot_map_trips_by_spatialcat.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{plot_map_trips_by_spatialcat} +\alias{plot_map_trips_by_spatialcat} +\title{Plots every type of trips(inside, outside, origin and destinating) on map} +\usage{ +plot_map_trips_by_spatialcat(trips_table, shape_table, crs, optimized = FALSE) +} +\arguments{ +\item{trips_table}{tibble of trips_output (from \link{read_output_trips})} + +\item{shape_table}{sf object(data.frame with geometries), can be received by using st_read(path_to_geographical_file)} + +\item{crs}{numeric representation of the EPSG code or proj4string for the corresponding coordinate system +of the trip coordinates, can be found in network file from output directory of MATSim simulation} + +\item{optimized}{bool, by default FALSE and gives interactive plot using leaflet, if TRUE creates image with ggplot} + +\item{table}{tibble of output_trips (from read_output_trips())} + +\item{shape_Table}{sf object(data frame with geometries), can be created using st_read(), is used to categorize the trips.} +} +\value{ +plot that contains every trip with defined trip type +} +\description{ +Plots every type of trips(inside, outside, origin and destinating) on map +} diff --git a/man/plot_spatialtype_by_shape_piechart.Rd b/man/plot_spatialtype_by_shape_piechart.Rd new file mode 100644 index 0000000..3395866 --- /dev/null +++ b/man/plot_spatialtype_by_shape_piechart.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{plot_spatialtype_by_shape_piechart} +\alias{plot_spatialtype_by_shape_piechart} +\title{Plots distribution of every type of trip(inside, outside, origin and destinating) as a pie chart} +\usage{ +plot_spatialtype_by_shape_piechart(trips_table, shape_table, crs) +} +\arguments{ +\item{trips_table}{tibble of trips_output (from \link{read_output_trips})} + +\item{crs}{numeric representation of the EPSG code or proj4string for the corresponding coordinate system of the trip coordinates, +can be found in network file from output directory of MATSim simulation} + +\item{shape_Table}{sf object(data frame with geometries), can be created using st_read(), is used to categorize the trips.} +} +\value{ +Pie chart showing the percentage of each type of trip +} +\description{ +Plots distribution of every type of trip(inside, outside, origin and destinating) as a pie chart +} diff --git a/man/plot_travelwaittime_mean_barchart.Rd b/man/plot_travelwaittime_mean_barchart.Rd new file mode 100644 index 0000000..7a76b99 --- /dev/null +++ b/man/plot_travelwaittime_mean_barchart.Rd @@ -0,0 +1,33 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{plot_travelwaittime_mean_barchart} +\alias{plot_travelwaittime_mean_barchart} +\title{Plot travel and wait time for each mode as a bar chart} +\usage{ +plot_travelwaittime_mean_barchart( + trips_table, + unite_modes = character(0), + united_name = "united", + time_format = "minute" +) +} +\arguments{ +\item{trips_table}{tibble of trips_output (from \link{read_output_trips})} + +\item{unite_modes}{vector of character strings, +changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +using the function (\link{process_rename_mainmodes})} + +\item{united_name}{character string, specifies the name of the united mode} + +\item{time_format}{A character string indicating the desired time format for the output. +The options are "minute", "hour", or "second". The default is "minute".} +} +\value{ +Bar Chart plot of average time spent on travel/wait +} +\description{ +Takes the data frame trips_output (from \link{read_output_trips}), +to plot a bar chart of travel and wait times. +Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') +} diff --git a/man/plot_trips_count_by_deptime_and_mainmode_linechart.Rd b/man/plot_trips_count_by_deptime_and_mainmode_linechart.Rd new file mode 100644 index 0000000..f8ee37e --- /dev/null +++ b/man/plot_trips_count_by_deptime_and_mainmode_linechart.Rd @@ -0,0 +1,29 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{plot_trips_count_by_deptime_and_mainmode_linechart} +\alias{plot_trips_count_by_deptime_and_mainmode_linechart} +\title{Line plot with departure time on x-axis and number of trips on y-axis} +\usage{ +plot_trips_count_by_deptime_and_mainmode_linechart( + trips_table, + unite_modes = character(0), + united_name = "united" +) +} +\arguments{ +\item{trips_table}{tibble of trips_output (from \link{read_output_trips})} + +\item{unite_modes}{vector of character strings, +changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt), +using the function (\link{process_rename_mainmodes})} + +\item{united_name}{character string, specifies the name of the united mode} +} +\value{ +Line plot of trips count by departure time per mode +} +\description{ +Takes data frame trips_output (from \link{read_output_trips}), +to create a line plot of the number of trips for a specific departure time by main_mode +Using the parameter unite_modes, specific modes can be renamed into one with the name specified with united_name (by default 'united') +} diff --git a/man/prepareComparisonSimwrapperDashboardFromTable.Rd b/man/prepareComparisonSimwrapperDashboardFromTable.Rd index 49ebfdf..01a51a1 100644 --- a/man/prepareComparisonSimwrapperDashboardFromTable.Rd +++ b/man/prepareComparisonSimwrapperDashboardFromTable.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/simwrapper.R \name{prepareComparisonSimwrapperDashboardFromTable} \alias{prepareComparisonSimwrapperDashboardFromTable} -\title{Creates comparison dashboard for the 2 given tables or folder with data} +\title{Creates comparison dashboard for the two given tables or folders with data} \usage{ prepareComparisonSimwrapperDashboardFromTable( table1, @@ -16,14 +16,14 @@ prepareComparisonSimwrapperDashboardFromTable( \item{table2}{trips_output tibble from readTripsTable()} -\item{dump.output.to}{folder that saves and configures yaml for simwrapper dashboard and all plots using functions: +\item{dump.output.to}{output folder, yaml files and plots from the following functions are saved there: plotModalSplitBarChart(),plotModalSplitPieChart(),plotModalShift().} -\item{append}{specifies if the ouput folder should be erased before creating} +\item{append}{specifies if the output folder should be erased before creating, default = FALSE} } \value{ -generates folder with content for simwrapper out of trips table +generates folder with content for simwrapper from a trips table } \description{ -Creates comparison dashboard for the 2 given tables or folder with data +Creates comparison dashboard for the two given tables or folders with data } diff --git a/man/prepareSimwrapperDashboardFromFolder.Rd b/man/prepareSimwrapperDashboardFromFolder.Rd index 975129c..ff41bee 100644 --- a/man/prepareSimwrapperDashboardFromFolder.Rd +++ b/man/prepareSimwrapperDashboardFromFolder.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/simwrapper.R \name{prepareSimwrapperDashboardFromFolder} \alias{prepareSimwrapperDashboardFromFolder} -\title{Creates dashboard for the given table or folder with data} +\title{Creates dashboard for the given folder with data} \usage{ prepareSimwrapperDashboardFromFolder( folder, @@ -11,15 +11,15 @@ prepareSimwrapperDashboardFromFolder( ) } \arguments{ -\item{folder}{specifies data source folder with tripsOutput} +\item{folder}{file path, specifies data source folder that includes a output_trips.csv file} -\item{dump.output.to}{folder that saves and configures yaml for simwrapper dashboard and all plots} +\item{dump.output.to}{output folder, yaml files are saved there} -\item{append}{specifies if the ouput folder should be erased before creating} +\item{append}{specifies if the ouput folder should be erased before creating, default = FALSE} } \value{ -tibble of output_trips from folder. Generates content needed for Simwrapper +tibble of output_trips from folder and content needed for Simwrapper } \description{ -Creates dashboard for the given table or folder with data +Creates dashboard for the given folder with data } diff --git a/man/prepareSimwrapperDashboardFromTable.Rd b/man/prepareSimwrapperDashboardFromTable.Rd index 3389d54..221603c 100644 --- a/man/prepareSimwrapperDashboardFromTable.Rd +++ b/man/prepareSimwrapperDashboardFromTable.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/simwrapper.R \name{prepareSimwrapperDashboardFromTable} \alias{prepareSimwrapperDashboardFromTable} -\title{Creates dashboard for the given table or folder with data} +\title{Creates dashboard for the given table with data} \usage{ prepareSimwrapperDashboardFromTable( table, @@ -13,14 +13,14 @@ prepareSimwrapperDashboardFromTable( \arguments{ \item{table}{trips_output tibble from readTripsTable()} -\item{dump.output.to}{folder that saves and configures yaml for simwrapper dashboard and all plots using functions: +\item{dump.output.to}{output folder, yaml files and plots from the following functions are saved there: plotModalSplitBarChart(),plotModalSplitPieChart(),plotModalShift().} -\item{append}{specifies if the ouput folder should be erased before creating} +\item{append}{specifies if the ouput folder should be erased before creating, default = FALSE} } \value{ generates folder with content for simwrapper out of trips table } \description{ -Creates dashboard for the given table or folder with data +Creates dashboard for the given table with data } diff --git a/man/processDtvEstimationQuality.Rd b/man/processDtvEstimationQuality.Rd index 907796e..abae3ea 100644 --- a/man/processDtvEstimationQuality.Rd +++ b/man/processDtvEstimationQuality.Rd @@ -14,7 +14,7 @@ processDtvEstimationQuality( \arguments{ \item{joinedFrame}{A tibble from mergeCountsAndLinks} -\item{aggr}{Boolean, if categorized data should returned aggregated} +\item{aggr}{Boolean, if categorized data should returned aggregated, default is TRUE.} \item{ll}{Formula to calculate lower limit of the quality label 'exact', default = 0.8*x - 200} @@ -25,13 +25,12 @@ A long-format tibble, which contains share of estimation quality for each scenar } \description{ Takes a tibble from mergeCountsAndLinks. -Deviation between count volumes and Linkstats is calculated -(e.g. deviation of 1.2 means 20 percent more DTV in MATSim than in counts) and -categorized. +Deviation between count volumes and Linkstats is calculated and +categorized (i.e. deviation of 1.2 means 20 percent more DTV in MATSim than in counts). If parameter 'aggr' is set to TRUE, data will be aggregated for each run and link type. Can be used to visualize model quality by link type and to compare several runs. } \details{ -Estimation quality is determinated by the 'cut' function, limits for the label -'exact' can be adjusted by tuning the parameter 'll' and 'ul' +Estimation quality is determined by the 'cut' function, limits for the label +'exact' can be adjusted by tuning the parameters 'll' (lower limit) and 'ul' (upper limit) } diff --git a/man/processLinkStatsDtvDistribution.Rd b/man/processLinkStatsDtvDistribution.Rd index c4afcc3..9763c07 100644 --- a/man/processLinkStatsDtvDistribution.Rd +++ b/man/processLinkStatsDtvDistribution.Rd @@ -2,21 +2,21 @@ % Please edit documentation in R/counts.R \name{processLinkStatsDtvDistribution} \alias{processLinkStatsDtvDistribution} -\title{Categorize DTV and calculate DTV distribution} +\title{Categorize daily traffic volume (DTV) and calculate DTV for different link types.} \usage{ processLinkStatsDtvDistribution(joinedFrame, from = 0, to = 40000, by = 5000) } \arguments{ \item{joinedFrame}{A tibble from mergeCountsAndLinks} -\item{from}{Lower limit for count bin} +\item{from}{Integer. Lower limit for count bin, default = 0.} -\item{to}{Upper limit for count bins} +\item{to}{Integer. Upper limit for count bins, default = 40000.} -\item{by}{Size of each count bin} +\item{by}{Integer. Size of each count bin, default = 5000.} } \value{ -A long-format tibble which contains share of DTV Categories +A long-format tibble which contains share of DTV for link types } \description{ Takes a tibble from mergeCountsAndLinks. DTV is categorized into bins. Finally diff --git a/man/process_append_distcat.Rd b/man/process_append_distcat.Rd new file mode 100644 index 0000000..b761458 --- /dev/null +++ b/man/process_append_distcat.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{process_append_distcat} +\alias{process_append_distcat} +\title{Adds additional \strong{dist_cat} column based on the \strong{distances_array} parameter} +\usage{ +process_append_distcat( + trips_table, + distances_array = c(1000, 2000, 5000, 10000, 20000, 50000, 1e+05) +) +} +\arguments{ +\item{trips_table}{tibble of output_trips (from \link{read_output_trips})} + +\item{distances_array}{numeric vector, represents segments for distance categories ordered (in meters), +standard value: c(1000,2000,5000,10000,20000,50000,100000)} +} +\value{ +trips table with added the added column dist_cat +} +\description{ +Categorizes each trip into a distance bin based on traveled distance. +E.g. distance traveled is 1500, distances array is (1000,2000), then the category is "1000-2000". +} diff --git a/man/process_append_spatialcat.Rd b/man/process_append_spatialcat.Rd new file mode 100644 index 0000000..d814a9d --- /dev/null +++ b/man/process_append_spatialcat.Rd @@ -0,0 +1,29 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{process_append_spatialcat} +\alias{process_append_spatialcat} +\title{Appends an additional column with the trip type to output_trips} +\usage{ +process_append_spatialcat(trips_table, shape_table, crs) +} +\arguments{ +\item{trips_table}{tibble of output_trips (from read_output_trips())} + +\item{crs}{numeric representation of the EPSG code or proj4string for the corresponding coordinate system +of the trip coordinates, can be found in network file from output directory of MATSim simulation} + +\item{shape_Table}{sf object(data frame with geometries), can be created using st_read(), is used to categorize the trips.} +} +\value{ +tibble, with additional column containing the trip type +} +\description{ +Using a shape_file of the project area an additional column is created, categorizing all trips into the following categories. +inside: trips that start and end inside the given shape +originating: trips that start inside the shape and end outside of the shape +destinating: trips that end inside the shape and start outside of the shape +outside: trips that start and end outside of the shape +} +\details{ +Please be aware that this \link{process_filter_by_shape} currently only works, when one geometry is loaded.) +} diff --git a/man/process_convert_table_to_sf.Rd b/man/process_convert_table_to_sf.Rd new file mode 100644 index 0000000..7795a57 --- /dev/null +++ b/man/process_convert_table_to_sf.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{process_convert_table_to_sf} +\alias{process_convert_table_to_sf} +\title{Transforms the data frame trips_output (from \link{read_output_trips}) from tibble to sf (table with geometry features)} +\usage{ +process_convert_table_to_sf(table, crs, geometry.type = st_multipoint()) +} +\arguments{ +\item{table}{tibble trips_output (from \link{read_output_trips})} + +\item{crs}{numeric, coordinate system in the form of the EPSG code or proj4string, can be found in the MATSim network file} + +\item{geometry.type}{type of sf transformation, default is st_multipoint(), geometry.type can be:\cr +!!!st_point()- resulting table contains two geometry columns: start_wkt and end_wkt, representing start and end points as POINTS!!! or\cr +!!!st_multipoint()- resulting table contains one geometry column, representing start and end points as MULTIPOINT!!! or\cr +!!!st_linestring() - resulting table contains one geometry column, representing the line between start and end points as LINESTRING!!!\cr} +} +\value{ +sf object (data frame with geometries depending on geometry.type) +} +\description{ +Transforms the data frame trips_output (from \link{read_output_trips}) into an sf object using start_x, end_x, start_y, end_y as geometry features.\cr +If geometry.type = st_multipoint() or geometry.type = st_linestring() it adds one geometry column (wkt format),\cr +if geometry.type = st_point() it adds the geometry columns start_wkt and end_wkt.\cr +Added column/columns are projected to given CRS (coordinate reference system).\cr +The columns start_x, end_x, start_y, end_y are deleted from the resulting data frame. +} diff --git a/man/process_convert_time.Rd b/man/process_convert_time.Rd new file mode 100644 index 0000000..2a5a02e --- /dev/null +++ b/man/process_convert_time.Rd @@ -0,0 +1,27 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{process_convert_time} +\alias{process_convert_time} +\title{Converts time column specified in \strong{time_column} to numeric representation of minutes, hours or seconds} +\usage{ +process_convert_time( + trips_table, + time_format = "hour", + time_column = "dep_time" +) +} +\arguments{ +\item{trips_table}{tibble of output_trips (from \link{read_output_trips})} + +\item{time_format}{char, defines time unit to be used ("hour", "minute", "second")} + +\item{time_column}{char, name of the column from table to be converted (\strong{dep_time}, \strong{trav_time}, \strong{wait_time})} +} +\value{ +tibble, containing column with specified time_format +} +\description{ +Default output_trips table time columns(\strong{dep_time}, \strong{trav_time}, \strong{wait_time}) are in 'hms' format. +To convert this type to numeric, specify \strong{time_column} to be converted, +and the unit \strong{time_format}. Acceptable units are "hour", "minute" and "second". +} diff --git a/man/process_filter_by_shape.Rd b/man/process_filter_by_shape.Rd new file mode 100644 index 0000000..1f2f915 --- /dev/null +++ b/man/process_filter_by_shape.Rd @@ -0,0 +1,30 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{process_filter_by_shape} +\alias{process_filter_by_shape} +\title{Filters trips_table(from ,\link{read_output_trips}) depending by location using a shapefile} +\usage{ +process_filter_by_shape(trips_table, shape_table, crs, spatial_type = "inside") +} +\arguments{ +\item{trips_table}{tibble of trips_output (from \link{read_output_trips})} + +\item{crs}{numeric representation of the EPSG code or proj4string for the corresponding coordinate system +of the trip coordinates, can be found in network file from output directory of MATSim simulation} + +\item{spatial_type}{bool, defines trips to conclude (see description)} + +\item{shape_Table}{sf object(data frame with geometries), can be created using st_read()} +} +\value{ +tibble, with filtered trips depending on shapeTable and spatial types (see description) +} +\description{ +Uses output_trips and an sf object (can be created using the function st_read()), +transforms both objects to match a mutual coordinate system (crs) +and filters the trips from output_trips depending on their spatial type:\cr +if spatial_type="inside" returns a table that contains trips inside given shape\cr +if spatial_type="originating" returns a table that contains trips which start inside the shape and end outside of the shape\cr +if spatial_type="destinating" returns a table that contains trips which end inside shape and start outside of the shape\cr +if spatial_type="outside" returns a table that contains trips which start and end outside of the given shape +} diff --git a/man/process_get_crs_from_config.Rd b/man/process_get_crs_from_config.Rd new file mode 100644 index 0000000..4839d7c --- /dev/null +++ b/man/process_get_crs_from_config.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{process_get_crs_from_config} +\alias{process_get_crs_from_config} +\title{Reads the coordinate reference system from a MATSim output directory (output_config.xml)} +\usage{ +process_get_crs_from_config(config_path) +} +\arguments{ +\item{config_path}{specifies path to configuration file} +} +\value{ +EPSG code of coordinate reference system +} +\description{ +Reads the coordinate reference system from a MATSim output directory (output_config.xml) +} diff --git a/man/process_get_mainmode_distribution.Rd b/man/process_get_mainmode_distribution.Rd new file mode 100644 index 0000000..94c2cea --- /dev/null +++ b/man/process_get_mainmode_distribution.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{process_get_mainmode_distribution} +\alias{process_get_mainmode_distribution} +\title{Calculates main mode distribution} +\usage{ +process_get_mainmode_distribution(trips_table, percentage = FALSE) +} +\arguments{ +\item{trips_table}{tible of output_trips (from \link{read_output_trips})} + +\item{percentage}{boolean, by default FALSE, sets if output should be given in percentage} +} +\value{ +tibble that provides the distribution of main modes in the input trips_table. +} +\description{ +The process_get_mainmode_distribution function calculates the distribution of main modes in a given trips_table.\cr +It provides insights into the frequency or percentage of each main mode within the dataset. +} +\details{ +By default, the function counts the occurrences of each main mode in the trips_table tibble and returns the counts for each unique main mode. \cr +Alternatively, when the percentage parameter is set to TRUE, the function normalizes the counts to represent the percentage distribution of each main mode within the dataset. +} diff --git a/man/process_get_od_matrix.Rd b/man/process_get_od_matrix.Rd new file mode 100644 index 0000000..a2cc88a --- /dev/null +++ b/man/process_get_od_matrix.Rd @@ -0,0 +1,39 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{process_get_od_matrix} +\alias{process_get_od_matrix} +\title{Creates an origin/destination matrix either in conventional form (row names = origin, column names = destination) +or for simwrapper (origin and destination as columns)} +\usage{ +process_get_od_matrix( + trips_table, + shape_path, + crs, + dump.output.to = matsimDumpOutputDirectory, + simwrapper = FALSE, + colnames = "numeric", + outer = FALSE +) +} +\arguments{ +\item{trips_table}{tibble of trips_output (from \link{read_output_trips})} + +\item{shape_path}{string, full path to the shapefile (.shp) (shape files are made up of several files with the same name and the folder also needs to include a .dbf file)} + +\item{crs}{numeric, coordinate system in the form of the EPSG code or proj4string, can be found in the MATSim network file} + +\item{dump.output.to}{string, path to a folder to save the .csv file} + +\item{simwrapper}{boolean, creates output in the format used for simwrapper if the path for the shapefile is specified} + +\item{colnames}{string, column names can be specified (i.e. to fit the shape file), if not they are numbered} + +\item{outer}{boolean, determines if flows outside of the shapefile are used, standard value is FALSE} +} +\value{ +tibble of origin/destination matrix +} +\description{ +Creates an origin/destination matrix either in conventional form (row names = origin, column names = destination) +or for simwrapper (origin and destination as columns) +} diff --git a/man/process_get_travdistance_distribution.Rd b/man/process_get_travdistance_distribution.Rd new file mode 100644 index 0000000..de86cd1 --- /dev/null +++ b/man/process_get_travdistance_distribution.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{process_get_travdistance_distribution} +\alias{process_get_travdistance_distribution} +\title{Get Travel Distance Distribution by Main Mode} +\usage{ +process_get_travdistance_distribution(trips_table, euclidean = FALSE) +} +\arguments{ +\item{trips_table}{A tibble of output_trips (from \link{\code{read_output_trips}})} + +\item{euclidean}{Logical value indicating whether to calculate the average as euclidean distance or as travel distance. Default is FALSE, which calculates the average traveled distance.} +} +\value{ +A tibble containing the main_mode column representing unique main modes and the avg_dist column representing the average travel distance for each main mode. +} +\description{ +The \code{process_get_travdistance_distribution} function calculates the distribution of travel distances based on main modes in a given trips_table tibble. It provides insights into the average distance traveled for each main mode. +} diff --git a/man/process_get_travelwaittime_by_mainmode.Rd b/man/process_get_travelwaittime_by_mainmode.Rd new file mode 100644 index 0000000..bff71c7 --- /dev/null +++ b/man/process_get_travelwaittime_by_mainmode.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{process_get_travelwaittime_by_mainmode} +\alias{process_get_travelwaittime_by_mainmode} +\title{Get Travel and Wait Time by Main Mode} +\usage{ +process_get_travelwaittime_by_mainmode(trips_table, time_format = "minute") +} +\arguments{ +\item{trips_table}{A tibble of output_trips (from \link{\code{read_output_trips}})} + +\item{time_format}{A character string indicating the desired time format for the output. The options are "minute", "hour", or "second". The default is "minute".} +} +\value{ +A tibble containing the main_mode column representing unique main modes, trav_time_avg column representing the average travel time for each main mode, and wait_time_avg column representing the average wait time for each main mode. +} +\description{ +The \code{process_get_travelwaittime_by_mainmode} function calculates the average travel time and average wait time for each main mode in a given trips_table tibble. +} diff --git a/man/process_rename_category.Rd b/man/process_rename_category.Rd new file mode 100644 index 0000000..6543b4e --- /dev/null +++ b/man/process_rename_category.Rd @@ -0,0 +1,32 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{process_rename_category} +\alias{process_rename_category} +\title{Replace Matching Categories of any column with United Name in Tibble} +\usage{ +process_rename_category( + trips_table, + unite_template = character(0), + united_name = "united", + column = "main_mode" +) +} +\arguments{ +\item{trips_table}{tible of output_trips (from \link{\code{read_output_trips}})} + +\item{unite_template}{vector of character string, representing pattern to match categories} + +\item{united_name}{character string, to represent new category for all occurrences matched unite_modes} + +\item{column}{tibble column name, which will be used in occurrences renaming} +} +\value{ +modified trips table tibble +} +\description{ +The \code{process_rename_category} function takes a tibble, trips_table, +as input and replaces all occurrences of categories +that match a given template with another name provided in united_name. +The function provides the flexibility to specify multiple category templates +to be united into a single name. +} diff --git a/man/process_rename_mainmodes.Rd b/man/process_rename_mainmodes.Rd new file mode 100644 index 0000000..e92d2e4 --- /dev/null +++ b/man/process_rename_mainmodes.Rd @@ -0,0 +1,30 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{process_rename_mainmodes} +\alias{process_rename_mainmodes} +\title{Replace Matching Categories of main_mode with United Name in Tibble} +\usage{ +process_rename_mainmodes( + trips_table, + unite_modes = character(0), + united_name = "united" +) +} +\arguments{ +\item{trips_table}{tibble of output_trips (from \link{\code{read_output_trips}})} + +\item{unite_modes}{vector of character strings, +changes names of chosen modes in the column main_mode to a new chosen name (i.e. drtNorth and drtSouth to drt)} + +\item{united_name}{character string, specifies the name of the united mode} +} +\value{ +tibble with new main_mode representation +} +\description{ +The process_rename_mainmodes function takes a tibble, trips_table, +as input and replaces all occurrences in column main_mode of categories +that match a given template with another name provided in united_name. +The function provides the flexibility to specify multiple category templates +to be united into a single name. +} diff --git a/man/readCounts.Rd b/man/readCounts.Rd index bcf3ae4..7ae29cc 100644 --- a/man/readCounts.Rd +++ b/man/readCounts.Rd @@ -10,8 +10,8 @@ readCounts(file) \item{file}{File to load. Must be an .xml file} } \value{ -tibble containing with MATSim Link id as "loc_id" as key +tibble with MATSim link id ("loc_id") as key } \description{ -Loads a MATSim Counts XML-File as tibble into memory +Loads a MATSim Counts XML-file as tibble into memory } diff --git a/man/readLinkStats.Rd b/man/readLinkStats.Rd index 30d169a..1d2ad08 100644 --- a/man/readLinkStats.Rd +++ b/man/readLinkStats.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/counts.R \name{readLinkStats} \alias{readLinkStats} -\title{Load linkstats as tibble into memory} +\title{Load a MATSim linkstats file into memory} \usage{ readLinkStats(runId, file, sampleSize = 0.25) } @@ -17,9 +17,9 @@ readLinkStats(runId, file, sampleSize = 0.25) Tibble with link stats for each qsim mode } \description{ -Reads Linkstats as .tsv created from LinkStats.class -as dataframe into memory. -Counts can be provided in any time bins. +Loads a linkstats tsv file created from the LinkStats class +as a dataframe into memory. +Counts can be provided in any time bin. Counts can be provided for any qsim mode. The argument networkModes is used to select and filter the columns. } diff --git a/man/readTripsTable.Rd b/man/read_config.Rd similarity index 50% rename from man/readTripsTable.Rd rename to man/read_config.Rd index fececb1..fce5fbb 100644 --- a/man/readTripsTable.Rd +++ b/man/read_config.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{readTripsTable} -\alias{readTripsTable} -\title{Load MATSIM output_trips table into Memory} +% Please edit documentation in R/config.R +\name{read_config} +\alias{read_config} +\title{Load MATSIM config file into Memory} \usage{ -readTripsTable(input_path = ".", n_max = Inf) +read_config(input_path = ".", n_max = Inf) } \arguments{ \item{input_path}{character string, path to matsim output directory or http link to the file.} @@ -15,6 +15,6 @@ readTripsTable(input_path = ".", n_max = Inf) tibble of trips_output } \description{ -Loads a MATSim CSV output_trips from file or archive, -creating a tibble with columns as in csv file +Loads a MATSim xml config from file or archive, +creating a list with parameters as in xml file } diff --git a/man/loadNetwork.Rd b/man/read_network.Rd similarity index 90% rename from man/loadNetwork.Rd rename to man/read_network.Rd index 9ac6c5b..90bddc2 100644 --- a/man/loadNetwork.Rd +++ b/man/read_network.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/network.R -\name{loadNetwork} -\alias{loadNetwork} +\name{read_network} +\alias{read_network} \title{Load MATSim network into memory} \usage{ -loadNetwork(filename) +read_network(filename) } \arguments{ \item{filename}{File to load. Can be XML or gzipped XML} @@ -19,6 +19,6 @@ additional columns in the respective node and link tibbles. } \details{ 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 +node x/y coordinates (and any other node attributes) are available in the links table without additional processing. } diff --git a/man/readPersonsTable.Rd b/man/read_output_persons.Rd similarity index 78% rename from man/readPersonsTable.Rd rename to man/read_output_persons.Rd index e393acb..2ede03a 100644 --- a/man/readPersonsTable.Rd +++ b/man/read_output_persons.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/personsOutput.R -\name{readPersonsTable} -\alias{readPersonsTable} +% Please edit documentation in R/output_persons.R +\name{read_output_persons} +\alias{read_output_persons} \title{Load MATSim output_persons table into memory} \usage{ -readPersonsTable(input_path = ".", n_max = Inf) +read_output_persons(input_path = ".", n_max = Inf) } \arguments{ \item{input_path}{is a character string, path to the local MATSim output directory, to the persons csv directly, or a http link to the file.} diff --git a/man/read_output_trips.Rd b/man/read_output_trips.Rd new file mode 100644 index 0000000..f05e2ff --- /dev/null +++ b/man/read_output_trips.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/output_trips.R +\name{read_output_trips} +\alias{read_output_trips} +\title{Load MATSim output_trips table into memory} +\usage{ +read_output_trips(input_path = ".", n_max = Inf) +} +\arguments{ +\item{input_path}{character string, path to the MATSim output directory or http link to the file} + +\item{n_max}{optional, integer, maximum number of lines to read, standard value is Inf} +} +\value{ +tibble of output_trips +} +\description{ +Loads MATSim output_trips.csv from file or archive creating a tibble +} diff --git a/man/transformToSf.Rd b/man/transformToSf.Rd deleted file mode 100644 index ec28139..0000000 --- a/man/transformToSf.Rd +++ /dev/null @@ -1,33 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/tripsOutput.R -\name{transformToSf} -\alias{transformToSf} -\title{Transforms trips_table tibble (from readTripsTable) from tibble to sf (table with attribute features and geometry feature)} -\usage{ -transformToSf(table, crs, geometry.type = st_multipoint()) -} -\arguments{ -\item{table}{tibble of trips_output (from readTripsTable())} - -\item{crs}{numeric of EPSG code or proj4string, can be found in network file from output directory of MATSim simulation} - -\item{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{ -sf object (data.frame with geometries depending to geometry.type) -} -\description{ -Takes trips_table (from readTripsTable) 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 -} -\details{ -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 -} diff --git a/tests/testthat/test-tripsOutput.R b/tests/testthat/test-output_trips.R similarity index 100% rename from tests/testthat/test-tripsOutput.R rename to tests/testthat/test-output_trips.R diff --git a/vignettes/.gitignore b/vignettes/.gitignore new file mode 100644 index 0000000..097b241 --- /dev/null +++ b/vignettes/.gitignore @@ -0,0 +1,2 @@ +*.html +*.R diff --git a/vignettes/Exampleproject.Rmd b/vignettes/Exampleproject.Rmd new file mode 100644 index 0000000..5f609a9 --- /dev/null +++ b/vignettes/Exampleproject.Rmd @@ -0,0 +1,118 @@ +--- +title: "Example project" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Example project} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, include=FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +``` + +The data used in this example project can be found on the [public repository] (https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/) from VSP Berlin. There you can also find other MATSim scenarios. + +#### Introduction + +This vignette offers an example workflow from MATSim output to thematic plots and maps. For a general overview of the package and its structure please read the introduction. + +A short recap however: functions are divided into four categories and start with a respective prefix. Read_, process_, plot_ or compare_ and in the future simwrapper_. +To better understand the naming conventions (for example to create your own functions) consult this vignette [LINK]. + +#### Installation + +MATSim R is not yet available at CRAN, so to install MATSim R using github, use the following code. + +```{r install master,eval=FALSE} +devtools::install_github("matsim-vsp/matsim-r") +``` + + +#### Loading the package + +Once installed, you can load the MATSim R package using the library() function: +```{r,eval=FALSE} +library(matsim) +library(sf) +``` + + +#### Loading data + +The data we'll use in this example project is the result of a Leipzig run which you can find under the following link. (https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/leipzig/projects/namav/base-case/) + +If you want to follow along, download a copy of the folder. + +To start, we will load the output_trips.csv.gz file. It is a zipped file, but that is okay, the functions can handle that. We will also load a shape file, which can be found here. (https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/leipzig/leipzig-v1.1/input/shp/) + +```{r,eval=FALSE} + trips_file_path <- "paste_file_path_here" + + # if you don't want to immediately load the whole file, the function read_output_trips has the option to only load the first n lines + output_trips <- read_output_trips(trips_file_path, n_max = 5000) +``` + + +#### Plot a modal split + +There are two functions to calculate and plot modal splits: `plot_mainmode_piechart()` and `plot_mainmode_piechart()`. As the name suggests the first one plots the modal split as a pie chart and the second one as a bar chart. To do this, they use the processing function `process_get_mainmode_distribution()` and plot the resulting table. The processing function can also be used on its own to just get the raw numbers. + +We are going to plot a bar chart: + +```{r,eval=FALSE} + plot_mainmode_barchart(output_trips) +``` + +The resulting bar chart looks like this: + +![Leipzig modal split](./Leipzig_modal_split.png) + +#### Spatial filter + +In a next step we want to spatially filter our data. So far we have been looking at all the trips in the simulation, now we want to focus on those that touch our project area. + +To do this we can use the function `process_filter_by_shape()` and the shape file we've already loaded. The parameter `crs` is the coordinate system number and the spatial_type describes the way the trips interact with the project area. The four options are inside, outside, originating and destinating. In this case we will look at the originating trips. + +```{r, eval = FALSE} +trips_originating <- process_filter_by_shape(output_trips, leipzig_shp, crs = 25832, spatial_type = "originating" ) +``` + +Using `plot_mainmode_barchart()` on the 507 originating trips, results in the following chart: + +![Leipzig modal split - trips originating in project area](./Leipzig_modalsplit_originating.png) + + +#### Comparison plots + +In a next step we will compare the modal split of this base model with the modal split of a scenario. To do this we need to load the output_trips file from a scenario, e.g. this one. https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/leipzig/projects/namav/drt-outskirts/ + +```{r, eval = FALSE} +#loading the scenario data +output_trips_scenario <- read_output_trips(trips_file_scenario_path, n_max = 5000) + +#filtering the scenario data +trips_scenario_originating <- process_filter_by_shape(output_trips_scenario, leipzig_shp, crs = 25832, spatial_type = "originating") + +#creating the comparison plot +plot_compare_mainmode_barchart(trips_originating, trips_scenario_originating) +``` + +The resulting plot looks like this: +![Leipzig modal split comparison](./Leipzig_modalsplit_comparison.png) + + +#### Maps + +The package also allows the plotting of spatial data. As an example we can plot the trips originating in the project area to see where they end. + +```{r,eval=FALSE} +plot_map_trips(trips_originating, crs = 25832) +``` + +The result is an interactive map using leaflet, showing the places of origin in blue and the destinations in red. (The following image is a screenshot) + +![Leipzig - originating trips](../inst/extdata/Leipzig_map.png) diff --git a/vignettes/Introduction.Rmd b/vignettes/Introduction.Rmd new file mode 100644 index 0000000..a6ef956 --- /dev/null +++ b/vignettes/Introduction.Rmd @@ -0,0 +1,115 @@ +--- +title: "Introduction to MATSim R Library: analyzing transport simulations" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Introduction to MATSim R Library: analyzing transport simulations} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +``` + +```{r setup, warning = FALSE} +library(matsim) +``` + +#### Introduction +Welcome to the MATSim R package! MATSim R is an R package designed for data processing and visualization and provides a wide range of functions to create adjustable plots from processed data. This vignette will give you an overview of the structure of the package and quickly guide you through the process of creating plots using the functions provided by the library. + +#### Overall concept + +The purpose of this package is to provide a comprehensive set of tools to efficiently analyze the output of MATSim runs. The package primarily processes output data stored in CSV and XML files, especially the so called "output_trips", "legs" and "persons" files. By adhering to this standardized naming convention, the package offers a streamlined functionality for reading, processing, plotting and YAML file creation for use in Simwrapper. XXXX LINK TO SIMWRAPPER GITHUB xxxx + +![Data flow and concept of matsim r package](./dataflow.png) + +The package is organized into four categories, each serving a specific purpose: + +**Reading Functions**: These functions begin with the prefix "read_" and are designed to read and import the simulation output. Field types are automatically set and a tibble is created. + +**Processing Functions**: Functions with the prefix "process_" form the core of the package's data manipulation capabilities. Users can apply a variety of transformations and calculations to the loaded tibbles, allowing for advanced processing and analysis tailored to their specific needs. Spatial input/output is also supported, enabling users to manipulate and analyze the data on a spatial level as well. + +**Plotting Functions**: The plotting functions with the prefix "plot_" enable users to create visualizations based on the processed output data. These functions offer a range of plotting options, allowing users to explore patterns, trends, and relationships within the simulation results. The plotting functions encompass two additional subcategories, namely ***mapping*** and ***comparing***. Within the mapping subcategory, users can generate visualizations that overlay simulation results onto geographical maps, providing insights into spatial patterns and distributions. The comparing subcategory offers tools to compare different simulation outputs, allowing analysis and understanding of variations between scenarios or data sets. + +**Simwrapper**: The simwrapper category is a specialized group within the package that facilitates plotting using YAML files in Simwrapper. This feature allows users to define complex plots and visualizations in the YAML format, providing a convenient and efficient way to generate custom visual representations of their simulation data. + +With this structure MATSim R aims to simplify the analysis of MATSim runs. It provides users with an intuitive workflow, from reading and processing the simulation output to generating informative plots and leveraging the power of YAML-based configurations. + + + +#### Installation +MATSim R is not yet available at CRAN, so to install MATSim R using github, you can use the following code: + +```{r install master,eval=FALSE} +devtools::install_github("matsim-vsp/matsim-r") +``` +However if you want to use a specific branch it can be specified like so: +```{r install ref,eval=FALSE} +devtools::install_github("matsim-vsp/matsim-r", ref = "{name of the branch}") +``` +#### Loading the package +Once installed, you can load the MATSim R package using the library() function: +```{r,eval=FALSE} +library(matsim) +``` + + + +#### Loading Data + +The first step in analyzing your transport simulations is to load the output data into your R environment. MATSim provides several functions with the "read_" prefix for this purpose. Let's take a look at how you can load your simulation output stored in a CSV file: + +```{r reading, warning=FALSE,eval = FALSE} +# Specify the file path to your simulation output. +# It can be a directory path or direct path to a file +output_file <- "path/to/your/output_trips.csv" + +# Use the read_csv_trips() function to read the simulation data +trips_data <- read_output_trips(output_file) +``` + +You can now proceed to explore and analyze the loaded data. + + +#### Data Processing + +MATSim R offers a range of processing functions, prefixed with "process_", to manipulate and transform your simulation data. These functions allow you to perform various operations, such as filtering, aggregating, and calculating additional metrics. Let's see an example of applying a transformation to our loaded data: +XXXX IS THE EXAMPLE CORRECT? - filter by shape?? XXXX + +```{r processing, warning=FALSE,eval=FALSE} +# Filter the trips data to include only weekday trips +weekday_trips <- process_filter_by_shape(trips_data) + +# Calculate the average trip duration +average_duration <- process_get_travelwaittime_by_mainmode(weekday_trips) +``` + +Feel free to explore the different processing functions available in the package to suit your specific analysis requirements. + +#### Plotting + +Visualizing your simulation data is crucial for gaining insights and effectively communicating your findings. MATSim R provides a wide range of plotting functions to help you create informative visualizations. Let's create a scatter plot to visualize the relationship between trip distance and trip duration: + + +```{r plotting, eval = FALSE} +# Create a scatter plot of trip distance among different main modes +plot_distance_by_mainmode_barchart(trips_data, x = "distance", y = "duration") +``` + +You can customize the plot appearance and explore other plot types, such as line plots, bar charts, and spatial maps, using the various plotting functions provided by MATSim R. + + +#### Advanced Features (still in development) + +- still in development - + + +#### Conclusion + +In this vignette, we introduced you to the MATSim R package, designed specifically for analyzing MATSim outputs. We hope that you'll have a great experience using this library and we are glad to receive feedback at **https://github.com/matsim-vsp/matsim-r/tree/master** or at mail **soboliev@vsp.tu-berlin.de** + +For more details and specific usage examples, refer to the package documentation and other vignettes available. Happy analyzing with MATSim R! diff --git a/vignettes/Introduction.html b/vignettes/Introduction.html new file mode 100644 index 0000000..e9d1278 --- /dev/null +++ b/vignettes/Introduction.html @@ -0,0 +1,394 @@ + + + + + + + + + + + + + + +Introduction for Matsim R Library + + + + + + + + + + + + + + + + + + + + + + + + + + +

Introduction for Matsim R Library

+ + + +
library(matsim)
+#> Warning: vorhergehender Import 'ggplot2::last_plot' durch 'plotly::last_plot'
+#> während des Ladens von 'matsim' ersetzt
+#> Warning: vorhergehender Import 'lubridate::stamp' durch 'reshape::stamp'
+#> während des Ladens von 'matsim' ersetzt
+#> Warning: vorhergehender Import 'plotly::rename' durch 'reshape::rename' während
+#> des Ladens von 'matsim' ersetzt
+#> Warning: vorhergehender Import 'purrr::discard' durch 'scales::discard' während
+#> des Ladens von 'matsim' ersetzt
+#> Warning: vorhergehender Import 'readr::col_factor' durch 'scales::col_factor'
+#> während des Ladens von 'matsim' ersetzt
+#> Warning: vorhergehender Import 'reshape::expand' durch 'tidyr::expand' während
+#> des Ladens von 'matsim' ersetzt
+

#Introduction Welcome to the matsim package! This +vignette will guide you through the process of creating plots using the +functions provided by our library. matsim is a powerful R package +designed for data process and visualization, with providing a wide range +of functions to create high-quality and adjustable plots from processed +data.

+

##Overall concept

+
+ +

Data flow and concept of matsim r package

+
+

##Installation Matsim is not still available at +CRAN, so to install matsim we use github, you can use the following +code:

+
devtools::install_github("matsim-vsp/matsim-r")
+

However if you want to have some specific branch in your Rstudio you +can specify this branch in the code:

+
devtools::install_github("matsim-vsp/matsim-r", ref = "{name of the branch}")
+

##Loading the package Once installed, you can load +the matsim package using the library() function:

+
library(matsim)
+ + + + + + + + + + + diff --git a/vignettes/Leipzig_map.png b/vignettes/Leipzig_map.png new file mode 100644 index 0000000..f728f78 Binary files /dev/null and b/vignettes/Leipzig_map.png differ diff --git a/vignettes/Leipzig_modal_split.png b/vignettes/Leipzig_modal_split.png new file mode 100644 index 0000000..be5e6b5 Binary files /dev/null and b/vignettes/Leipzig_modal_split.png differ diff --git a/vignettes/Leipzig_modalsplit_comparison.png b/vignettes/Leipzig_modalsplit_comparison.png new file mode 100644 index 0000000..2de768b Binary files /dev/null and b/vignettes/Leipzig_modalsplit_comparison.png differ diff --git a/vignettes/Leipzig_modalsplit_originating.png b/vignettes/Leipzig_modalsplit_originating.png new file mode 100644 index 0000000..32000b6 Binary files /dev/null and b/vignettes/Leipzig_modalsplit_originating.png differ diff --git a/vignettes/Namings.Rmd b/vignettes/Namings.Rmd new file mode 100644 index 0000000..e8c08d0 --- /dev/null +++ b/vignettes/Namings.Rmd @@ -0,0 +1,162 @@ +--- +title: "Namings" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{Namings} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +``` + + +#### Overview + +All function names are built using the same naming template. Functions start with a specific verb (e.g. read, plot, process) that describes their main usage. 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. + +- plot +- read +- process + +**{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: + +- compare +- map + +For processing functions: + +- get +- rename +- append +- filter +- convert + +**[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 + +- plot_arrtime_by_act + - plot: Indicates that this function is used to plot data. + - arrtime: Refers to "Arrival Time," which is the key aspect being visualized. + - by_act: Indicates that the plot is grouped by "Activity." + +- plot_compare_count_by_spatialcat_barchart + - plot: Indicates that this function is used to plot data. + - compare_count: Refers to comparing the count of trips. + - by_spatialcat: Indicates that the comparison is based on "Spatial Categories." + - barchart: Specifies the type of plot used for visualization. + +- plot_compare_distcat_by_mainmode_barchart + - plot: Indicates that this function is used to plot data. + - compare_distcat: Refers to comparing the distribution of trips based on "Distance Categories." + - by_mainmode: Indicates that the comparison is based on different "Main Modes." + - barchart: Specifies the type of plot used for visualization. + +- plot_compare_mainmode_barchart + - plot: Indicates that this function is used to plot data. + - compare_mainmode: Refers to comparing different "Main Modes." + - barchart: Specifies the type of plot used for visualization. + +- plot_compare_mainmode_sankey + - plot: Indicates that this function is used to plot data. + - compare_mainmode: Refers to comparing different "Main Modes." + - sankey: Specifies the type of plot used for visualization, which is a "Sankey Diagram." + +- plot_compare_travelwaittime_by_mainmode + - plot: Indicates that this function is used to plot data. + - compare_travelwaittime: Refers to comparing the "Travel Time" and "Wait Time." + - by_mainmode: Indicates that the comparison is based on different "Main Modes." + +- plot_compare_travelwaittime_by_mainmode_barchart + - plot: Indicates that this function is used to plot data. + - compare_travelwaittime: Refers to comparing the "Travel Time" and "Wait Time." + - by_mainmode: Indicates that the comparison is based on different "Main Modes." + - barchart: Specifies the type of plot used for visualization. + +- plot_deptime_by_act + - plot: Indicates that this function is used to plot data. + - deptime: Refers to "Departure Time," which is the key aspect being visualized. + - by_act: Indicates that the plot is segmented or grouped by "Activity." + +- plot_distance_by_mainmode_barchart + - plot: Indicates that this function is used to plot data. + - distance: Refers to "Distance," which is the key aspect being visualized. + - by_mainmode: Indicates that the plot is segmented or grouped by different "Main Modes." + - barchart: Specifies the type of plot used for visualization. + +- plot_distance_by_spatialcat_barchart + - plot: Indicates that this function is used to plot data. + - distance: Refers to "Distance," which is the key aspect being visualized. + - by_spatialcat: Indicates that the plot is segmented or grouped by "Spatial Categories." + - barchart: Specifies the type of plot used for visualization. + +- plot_distcat_by_mainmode_barchart + - plot: Indicates that this function is used to plot data. + - distcat: Refers to "Distance Categories," which is the key aspect being visualized. + - by_mainmode: Indicates that the plot is segmented or grouped by different "Main Modes." + - barchart: Specifies the type of plot used for visualization. + +- plot_mainmode_barchart + - plot: Indicates that this function is used to plot data. + - mainmode: Refers to "Main Modes," which is the key aspect being visualized. + - barchart: Specifies the type of plot used for visualization. + +- plot_mainmode_piechart + - plot: Indicates that this function is used to plot data. + - mainmode: Refers to "Main Modes," which is the key aspect being visualized. + - piechart: Specifies the type of plot used for visualization. + +- plot_map_trips + - plot: Indicates that this function is used to plot data. + - map_trips: Refers to "Mapping of Trips," which is the key aspect being visualized. + +- process_append_distcat + - process: Indicates that this function is used to process data. + - append_distcat: Refers to appending "Distance Categories" to the trips_table. + +- process_append_spatialcat + - process: Indicates that this function is used to process data. + - append_spatialcat: Refers to appending "Spatial Categories" to the trips_table. + +- process_convert_table_to_sf + - process: Indicates that this function is used to process data. + - convert_table_to_sf: Refers to converting the trips_table to a spatial data frame (sf). + +- process_convert_time + - process: Indicates that this function is used to process data. + - convert_time: Refers to converting time data in the trips_table to a specified format. + +- process_filter_by_shape + - process: Indicates that this function is used to process data. + - filter_by_shape: Refers to filtering trips in the trips_table based on a shape. diff --git a/vignettes/dataflow.png b/vignettes/dataflow.png new file mode 100644 index 0000000..02f8cf1 Binary files /dev/null and b/vignettes/dataflow.png differ