str_order | R Documentation |
str_sort()
returns the sorted vector.
str_order()
returns an integer vector that returns the desired
order when used for subsetting, i.e. x[str_order(x)]
is the same
as str_sort()
str_rank()
returns the ranks of the values, i.e.
arrange(df, str_rank(x))
is the same as str_sort(df$x)
.
str_order(
x,
decreasing = FALSE,
na_last = TRUE,
locale = "en",
numeric = FALSE,
...
)
str_rank(x, locale = "en", numeric = FALSE, ...)
str_sort(
x,
decreasing = FALSE,
na_last = TRUE,
locale = "en",
numeric = FALSE,
...
)
x |
A character vector to sort. |
decreasing |
A boolean. If |
na_last |
Where should |
locale |
Locale to use for comparisons. See
|
numeric |
If |
... |
Other options used to control collation. Passed on to
|
A character vector the same length as string
.
stringi::stri_order()
for the underlying implementation.
x <- c("apple", "car", "happy", "char")
str_sort(x)
str_order(x)
x[str_order(x)]
str_rank(x)
# In Czech, ch is a digraph that sorts after h
str_sort(x, locale = "cs")
# Use numeric = TRUE to sort numbers in strings
x <- c("100a10", "100a5", "2b", "2a")
str_sort(x)
str_sort(x, numeric = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.