rts2list {ghroute}R Documentation

Split route result matrix by index

Description

rts2list converts route result matrix into a list of individual matrices based on the supplied index which is typically part of the matrix.

Usage

rts2list(rts, nrow = max(index), index = rts[, 3])

Arguments

rts

matrix

nrow

total number of input rows

index

index mapping rows of the matrix to result rows

Details

The matrix rts is split into indiviudal matrices according to the index. It is similar to split(rts, index) except that the result has exactly nrow entries corresponding the the indices 1 .. nrow and index must be contiguous. Any missing entries (i.e., indices between 1 and nrow which are not in index) are filled with NULL.

Value

A list of exactly nrow elements. The entries are either NULL (index not present) or the corresponding slice of the matrix.

Author(s)

Simon Urbanek

Examples

m = matrix(1:10,, 2)
rts2list(m, 3, c(1,1,1,3,3))

## route matrices have the index as 3rd column
m = cbind(m, c(1,1,1,3,3))

## let's say the input had 5 pairs
rts2list(m, 5)


[Package ghroute version 0.2-0 Index]