| which.min.key {iotools} | R Documentation |
which.min.key takes either a character vector or a list of
strings and returns the location of the element that is
lexicographically (using bytewise comparison) the first. In a sense
it is which.min for strings. In addition, it supports prefix
comparisons using a key delimiter (see below).
which.min.key(keys, sep = "|")
keys |
character vector or a list of strings to use as input |
sep |
string specifying the key delimiter. Only the first
character is used. Can be |
which.min.key considers the prefix of each element in
keys up to the delimiter specified by sep. It returns
the index of the element which is lexicographically first among all
the elements, using bytewise comparison (i.e. the locale is not used
and multi-byte characters are not considered as one character).
If keys is a character vector then NA elements are
treated as non-existent and will never be picked.
If keys is a list then only string elements of length > 0 are
eligible and NAs are not treated specially (hence they will
be sorted in just like the "NA" string).
scalar integer denoting the index of the lexicographically first
element. In case of a tie the lowest index is returned. If there are
no eligible elements in keys then a zero-length integer vector
is returned.
Simon Urbanek
which.min.key(c("g","a","b",NA,"z","a"))
which.min.key(c("g","a|z","b",NA,"z|0","a"))
which.min.key(c("g","a|z","b",NA,"z|0","a"), "")
which.min.key(list("X",1,NULL,"F","Z"))
which.min.key(as.character(c(NA, NA)))
which.min.key(NA_character_)
which.min.key(list())