| label_date_jp | R Documentation |
Formats date labels using the Japanese calendar system and returns labels suitable for use with ggplot2 scales.
label_date_jp(labels, format = default_format(), tz = NULL)
label_date_jp_gen(format = default_format(), tz = NULL)
labels |
A vector of values coercible to Date objects. |
format |
A date-time format string following ICU conventions. |
tz |
A time zone used when coercing values to Date objects. |
This labeller formats dates according to a locale-aware Japanese calendar, allowing era-based representations such as Reiwa or Heisei. The output is intended for discrete or continuous date scales in ggplot2.
label_date_jp() returns a character vector of formatted date labels.
label_date_jp_gen() returns a labeller function for use in ggplot2 scales.
date_range <- function(start, days) {
start <- as.POSIXct(start)
c(start, start + days * 24 * 60 * 60)
}
two_months <- date_range("2025-12-31", 60)
label_date_jp(two_months)
if (requireNamespace("scales", quietly = TRUE)) {
scales::demo_datetime(two_months, labels = label_date_jp_gen())
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.