| mixtime-order | R Documentation |
sort() and xtfrm() (which powers order() and rank()) order a mixtime
vector chronologically. A discrete time (e.g. yearmonth("2020 Jan")) is a
span rather than an instant, so ordering it against time of another
chronon first picks an instant within the span.
align_discrete sets that instant: 0 for the start of the span, 1 for
its end, and 0.5 (the default) for its midpoint. It only changes the order
of time with different chronons; time sharing a chronon keeps its order.
xtfrm() takes no other arguments, so order(), rank() and vctrs
ordering always use the midpoint. Use sort() to choose another instant.
## S7 method for class <mixtime::mixtime>
xtfrm(x)
## S7 method for class <mixtime::mixtime>
sort(x, decreasing = FALSE, na.last = NA, ..., align_discrete = 0.5)
x, decreasing, na.last, ... |
See |
align_discrete |
The position within a discrete time span used to
order it against time of another chronon, from |
sort() returns a mixtime vector; xtfrm() returns a numeric vector
suitable for ranking.
x <- c(yearmonth("2020 Jan"), date("2020-01-20"), yearmonth("2020 Feb"))
sort(x)
# January ends after the 20th
sort(x, align_discrete = 1)
sort(x, decreasing = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.