View source: R/yr_sort_range.R
yr_sort | R Documentation |
Sorts a vector of years into earliest-to-latest or latest-to-earliest chronological order based on its era.
yr_sort(x, reverse = FALSE, ...)
x |
yr vector with era |
reverse |
Set |
... |
Other arguments passed to |
This is implemented as a prefixed function rather than an S3 sort()
method
for yrs to avoid surprises when numerical (i.e. not chronological) sorting
is expected.
Sorted yr vector
Other functions for chronological ordering and extremes:
yr_extremes
# Forward-counting era:
x <- yr(c(200, 100, 300), "CE")
yr_sort(x)
yr_sort(x, reverse = TRUE)
# Backward-counting era:
y <- yr(c(200, 100, 300), "BCE")
yr_sort(y)
yr_sort(y, reverse = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.