View source: R/arrange_natural.R
arrange_natural | R Documentation |
arrange_natural()
orders the rows of a data frame by the values of selected
columns.
Data is naturally sorted (see Details, below) in ascending order. Columns used for sorting are converted to factors to preserve their ordering. Grouping is ignored.
arrange_natural(.data, ...)
.data |
A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr). |
... |
< |
arrange_natural()
is built on dplyr::arrange()
to provide
natural sorting
(sorting of strings with both letters and numerals). The underlying
implementation for natural sorting is based on the
stringi library.
An object of the same type as .data
. The output has the following
properties:
All rows appear in the output, but (usually) in a different place.
Sorted columns are converted to factors.
All other columns are not modified.
Data frame attributes are preserved.
dplyr::arrange()
df <- tibble::tribble(
~sample, ~gene,
"D10-23", "atp6",
"D10-43", "mdr1",
"D10-55", "atp6",
"D10-5", "mdr1",
"D10-47", "dhps",
"D10-15", "atp6"
)
arrange_natural(df, sample)
df %>% arrange_natural(sample, gene)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.