Compares two Versatrans RP databases and reports the differences. Incidental changes
can be ignored by setting appropriate threshold parameter values.
Usage
report_routechanges(
database_old = Sys.getenv("RP_DATABASE_PEND"),
database_new = Sys.getenv("RP_DATABASE_PLAN"),
load_threshold = 5,
time_threshold = 3,
distance_threshold = 100
)
Arguments
- database_old
Name of the old database to use
- database_new
Name of the new database to use
- load_threshold
Minimum load change required to trigger a load change flag
- time_threshold
Minimum route time change required to trigger a time change flag
- distance_threshold
Minimum route distance change required to trgger a distance change flag
Value
A data.frame
with columns indicating the attributes for each modified route.
The VisibleRouteID
, VehicleTrip
, and Notes
columns identify and summarize route changes.
For each attribute the remaining columns list the diff
erence along with the values of
each attribute in the .old
ing and .new
ing databases.
The column names are orgainized as follows:
- VisibleRouteID
visible route identification number, uniquely identifies each row
- VehicleTrip
vehicle and trip info, combined for convenience
- Notes
notes describing changes made to the route
- ActualLoad. diff/old/new
number of riders assigned to route
- AnchorLocation. diff/old/new
route anchor location
- AnchorTime. diff/old/new
route anchor time
- Days. diff/old/new
days on which the route is scheduled to run
- DesiredLoad. diff/old/new
vehicle desired load
- Direction. diff/old/new
trip direction,
I
nbound/am orO
utbound/pm- n_Stops. diff/old/new
number of stop changes
- Name. diff/old/new
route name
- Route. diff/old/new
visible route identification number
- RouteDistance. diff/old/new
route distance
- RouteSet. diff/old/new
route set name
- RouteTime. diff/old/new
expected route time
- Stops. diff/old/new
stops added or removed
- Vehicle. diff/old/new
vehicle identification number
- Yard. diff/old/new
vehicle overnight yard
Examples
library(dplyr); library(tidyr) ## for convenience, not required
#>
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#>
#> filter, lag
#> The following objects are masked from ‘package:base’:
#>
#> intersect, setdiff, setequal, union
changes <- report_routechanges()
#> Error in tidyr::pivot_longer(route_changes, cols = c(dplyr::ends_with(".diff"), dplyr::ends_with(".old"), dplyr::ends_with(".new")), names_to = c("Variable", ".value"), names_sep = "\\.", values_transform = list(diff = as.integer, old = as.character, new = as.character), values_drop_na = TRUE): Can't combine `Name.old` <character> and `AnchorTime.old` <logical>.
## The data is structured like this:
glimpse(changes[0,])
#> Error in changes[0, ]: object of type 'closure' is not subsettable
## It may sometimes be convenient to work with these data in a "long" format,
## which you can do using standard tools for this purpose:
longChanges <- pivot_longer(
changes,
cols=c(ends_with(".diff"), ends_with(".new"), ends_with(".old")),
names_to = c("Variable", ".value"),
values_transform = list(diff = as.integer, old = as.character, new = as.character),
names_sep = "\\.")
#> Error in UseMethod("pivot_longer"): no applicable method for 'pivot_longer' applied to an object of class "function"
glimpse(longChanges[0,])
#> Error in glimpse(longChanges[0, ]): object 'longChanges' not found