View source: R/50-ordered_sequence-constructors.R
| as_ordered_sequence | R Documentation |
x and keysConstructs an ordered_sequence by pairing each element of x with the
corresponding key in keys.
as_ordered_sequence(x, keys)
x |
Elements to add. |
keys |
Key values with the same length as |
Output is always sorted by key.
Duplicate keys are allowed; ties preserve input order (stable/FIFO within the same key).
Names on x are preserved as element names.
An ordered_sequence.
xs <- as_ordered_sequence(c("d", "a", "b", "a2"), keys = c(4, 1, 2, 1))
xs
length(elements_between(xs, 1, 1))
n <- as_ordered_sequence(setNames(as.list(c("a", "b")), c("ka", "kb")), keys = c(2, 1))
n[["kb"]]
# Keys can be other comparable types
num_by_chr <- as_ordered_sequence(c(20, 10, 30), keys = c("b", "a", "c"))
num_by_chr
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.