Generate ordered ids of OD pairs so lowest is always first This function is slow on large datasets, see szudzik_pairing for faster alternative
Source:R/oneway.R
od_id_order.Rd
Generate ordered ids of OD pairs so lowest is always first This function is slow on large datasets, see szudzik_pairing for faster alternative
Arguments
- x
A data frame or SpatialLinesDataFrame, representing an OD matrix
- id1
Optional (it is assumed to be the first column) text string referring to the name of the variable containing the unique id of the origin
- id2
Optional (it is assumed to be the second column) text string referring to the name of the variable containing the unique id of the destination
See also
Other od:
od2line()
,
od2odf()
,
od_aggregate_from()
,
od_aggregate_to()
,
od_coords()
,
od_coords2line()
,
od_id
,
od_oneway()
,
od_to_odmatrix()
,
odmatrix_to_od()
,
points2flow()
,
points2odf()
Examples
x <- data.frame(id1 = c(1, 1, 2, 2, 3), id2 = c(1, 2, 3, 1, 4))
od_id_order(x) # 4th line switches id1 and id2 so stplanr.key is in order
#> stplanr.id1 stplanr.id1.1 stplanr.key
#> 1 1 1 1 1
#> 2 1 2 1 2
#> 3 2 3 2 3
#> 4 2 1 1 2
#> 5 3 4 3 4