mergeSortedLists | R Documentation |
Given a list of numeric vectors, in each of which there come almost
increasing sequences (that can be interrupted by decreasing values),
mergeSortedLists
merges them such that
i) the relative order of any two values from an individual vector is
preserved in the result, and
ii) the resulting vector is sorted in increasing order, if this would
not invalidate the first condition.
In case of ties, the value from former vector takes precedence.
For example: the list list(c(1,3,5,3), c(2,4,1,2))
gives the
result of c(1,2,3,4,1,2,5,3)
.
mergeSortedLists(x, dbg = 0)
x |
a list of numeric vectors |
dbg |
debug level |
A list of two numeric vectors:
x
, the resulting vector of merged values, and
idx
, the indices of the selected values.
Tomas Sieger
mergeSortedLists(list(c(1,3,5,3), c(2,4,1,2)),dbg=1)
mergeSortedLists(list(1:10))
mergeSortedLists(list(1:2,1:2))
mergeSortedLists(list(c(),1,c()))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.