rts2list {ghroute} | R Documentation |
rts2list
converts route result matrix into a list of individual
matrices based on the supplied index which is typically part of the
matrix.
rts2list(rts, nrow = max(index), index = rts[, 3])
rts |
matrix |
nrow |
total number of input rows |
index |
index mapping rows of the matrix to result rows |
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
.
A list of exactly nrow
elements. The entries are either
NULL
(index not present) or the corresponding slice of the
matrix.
Simon Urbanek
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)