yr_extremes | R Documentation |
Returns the chronologically earliest and/or latest value in a vector of
years, i.e. era-aware version min()
, max()
, and range()
.
yr_earliest(x, na.rm = FALSE)
yr_latest(x, na.rm = FALSE)
yr_range(x, na.rm = FALSE)
x |
A yr vector with era |
na.rm |
a logical indicating whether missing values should be removed |
These are implemented as prefixed functions rather than S3 min()
, max()
,
and range()
methods for yrs to avoid surprises when numerical (i.e. not
chronological) extremes are expected.
For yr_earliest()
and yr_leatest()
, a yr
vector of length 1 with the
earliest or latest value.
For yr_range()
, a yr
vector of length 2 with the earliest and latest
value (in that order).
If x
contains NA
values and na.rm = FALSE
(the default), only NA
s
will be returned.
Other functions for chronological ordering and extremes:
yr_sort()
# Forward-counting era:
x <- yr(c(200, 100, 300), "CE")
yr_earliest(x)
yr_latest(x)
yr_range(x)
# Backward-counting era:
y <- yr(c(200, 100, 300), "BCE")
yr_earliest(y)
yr_latest(y)
yr_range(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.