knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

saturnR

Overview

This package is a wrapper on saturn traffic modelling software to improve saturn and R workflow. It's functions use SATURN built in XEXES as a backend and allow R users to interact with the most common SATURN files such as UFM matrices and UFS files

Currently you can:

Installation

# You can install the the development version from GitHub:
# install.packages("devtools")
devtools::install_github("fermumen/saturnR")

Intro to Matrix manipulation

Matrix manipulation using the built in tools in Saturn can be cumbersome whith this package you can load the data into R modify it and save it again.

The Package comes with some example files for you to test you can see them with

library(saturnR)
saturnR_example()

To modify the example Epsom98 matrix first we need to set up out XEXES folder as our back end.

# Using a particular version of the backend
set_xexes("C:/Program Files (x86)/Atkins/SATURN/XEXES 11.4.07H MC X7/")

The we can read the matrix. It only has one user class, 12 zones and 144 rows

epsom_mat <- saturnR_example("Epsom98mat.UFM")

mat <- read_ufm(epsom_mat)

mat

If we wanted to anlayse the trips between zone 3 and 4 we could use:

selected_trips <- (mat$origin == 3 & mat$destination == 4) | # from 3 to 4
  (mat$origin == 4 & mat$destination == 3) # or from 4 to 3

mat[selected_trips, ]

Then we can increase them by a fixed ammount.

fixed_increase <- 200 # A new development adds 200 trips

mat$trips[selected_trips] <- mat$trips[selected_trips] + fixed_increase

mat[selected_trips, ]

Finally we could save the matrix

write_ufm(mat, "Epsom_new_dev.UFM")


R-AECOM/SaturnR documentation built on Nov. 26, 2022, 2:46 p.m.