| unit_scheme | R Documentation |
Builds the function a unit_labels() method is: assign its result
directly, e.g. method(unit_labels, granule) <- unit_scheme(...). A unit
scheme names a granule itself, e.g. the "month" in "3 months", and is the
single source of truth for every output that renders a count of a unit:
duration formatting and parsing (dur() tokens), granule labels
(format(month(3L))), tsibble interval displays and messages.
unit_scheme(vocab, symbol = "", locale = NULL)
unit_labels(granule, ...)
vocab |
A function |
symbol |
A short identifier for the unit, e.g. |
locale |
A caller-overridable default locale, selecting which
|
granule |
A time granule instance (e.g. |
... |
Unused; only present for S7 dispatch. |
method(unit_labels, cal_gregorian$month) <- unit_scheme(
vocab = vocab_table(`en-GB` = list(wide = "month{?/s}")),
symbol = "M"
)
This differs from a label_scheme(), which labels the values of a
granule (e.g. "March" or "2024") rather than the granule itself, but the
two share the same vocab and locale fields.
A function function(granule) list(vocab =, symbol =, locale =),
assignable directly as a unit_labels() method. granule is only used
for dispatch: a scheme describes a granule class, not the instance a
method happens to be called with.
unit_labels(), the generic a scheme is returned from;
label_scheme() for labelling the values of a granule; vocab_table()
for the common hand-listed name table case.
scheme <- unit_labels(cal_gregorian$year(1L))
scheme$vocab("wide")
scheme$symbol
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.