| linear_labels_format | R Documentation |
The generics turning a granule's internal position into display text
(linear_labels_format() for a non-repeating position, e.g. the year;
cyclical_labels_format() for a position within a larger cycle, e.g. the
month within the year) and back (linear_labels_parse()/
cyclical_labels_parse()).
linear_labels_format(granule, ...)
cyclical_labels_format(granule, cycle, ...)
linear_labels_parse(granule, ...)
cyclical_labels_parse(granule, cycle, ...)
granule |
A time granule object representing the granule (e.g.
|
... |
Passed on to the method. The default method (see below) takes:
|
cycle |
A time granule object representing the cycle (e.g.
|
Each has one default method (on the base mt_unit class) that looks up
the granule's scheme via linear_labels()/cyclical_labels() and
applies it (see label_scheme() for the fields). Calendar authors
usually declare a scheme instead of writing a method here directly.
Writing one directly overrides the generics for labels that aren't
index-shaped at all, see linear_labels()'s "Overriding the generics
directly" section.
Character vector of labels for the time point.
linear_labels_format()'s i arrives already epoch-shifted for display
(chronon_parts() adds chronon_epoch() before calling it, e.g. a
Gregorian year's i is 2024, not 54). The default
linear_labels_parse() method shifts decode()'s output back, by
subtracting chronon_epoch() after the scheme's own decode runs. A
hand-written override method skips this and must do the same
subtraction itself if the granule has a non-zero epoch; see the example
in linear_labels().
linear_labels()/cyclical_labels() for the authoring
interface these generics' default methods interpret.
# Labels for years on a linear axis
with(cal_gregorian, linear_labels_format(year(1L), 2020:2025))
# Labels for months in a year
with(cal_gregorian, cyclical_labels_format(month(1L), year(1L), 0:11))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.