yr_sort {era} | R Documentation |
Chronological ordering of year vectors
Description
Sorts a vector of years into earliest-to-latest or latest-to-earliest chronological order based on its era.
Usage
yr_sort(x, reverse = FALSE, ...)
Arguments
x |
yr vector with era |
reverse |
Set |
... |
Other arguments passed to |
Details
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.
Value
Sorted yr vector
See Also
Other functions for chronological ordering and extremes:
yr_extremes
Examples
# 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)
[Package era version 0.5.0 Index]