Returns the key of the element at a one-based position, without removing it.
This is the positional companion to peek_at() (which returns the value at a
position) and the general form of min_key() (key_at(x, 1)) and
max_key() (key_at(x, length(x))).
Details
Positive integer indices beyond length(x) return NULL. Invalid indices
(NA, non-integer, <= 0, or length not equal to 1) error. Pair with
peek_at() to read the value at the same position, or use pop_at() when
you also want the remaining sequence.
Examples
x <- ordered_sequence("a", "b", "c", keys = c(10, 20, 30))
key_at(x, 2)
#> [1] 20
key_at(x, 10)
#> NULL
