plot_mdate: Plot messy dates

plot_mdateR Documentation

Plot messy dates

Description

plot() draws one line for each messy date, so that its imprecision can be seen before it is resolved. The height of each shape is the weight of each possible day:

  • A precise date is a point.

  • A range, or a value with year or month precision, is a bar of full height, because each of its days has the same weight.

  • A set, or a value with unspecified digits (X), shows each of its possible dates as a point, joined by a dotted line.

  • An approximate value (~ or ⁠%⁠), with approx_range more than 0, is a trapezoid: a full-height core across the dates that the value names, and sides that fall to 0 over the dates that approx_range adds. These are the weights that vrandom() uses.

  • An uncertain value (⁠?⁠ or ⁠%⁠) has a dashed outline and no fill, because the source doubts the record, but its dates do not change.

Missing values and the empty set, {}, are not drawn. A time of day is not drawn; each value is drawn by its days.

Usage

## S3 method for class 'mdate'
plot(x, labels = NULL, approx_range = 0, sort = TRUE, main = NULL, ...)

Arguments

x

An mdate object.

labels

A character vector of labels, one for each element of x. By default, the messy dates themselves.

approx_range

The number of units that an approximate value widens by on each side, as in compatible_dates(). By default 0, so that approximate values are drawn as if they were not approximate.

sort

Should the lines be sorted by the earliest possible date? TRUE by default. If FALSE, the lines are in the order of x.

main

A title for the plot.

...

Other arguments passed to plot.default().

Value

A data frame, invisibly, with the value, label, earliest day and latest day of each element that was drawn, in the order drawn from the top.

Examples

plot(battles$Date, labels = battles$Battle)
plot(as_messydate(c("2012-03-15", "2012-04", "2012-05-10..2012-06-20",
                    "2012-07-~15", "2012-~09", "2012-10?",
                    "{2012-02-01,2012-11-15}", "2012-XX-28")),
     approx_range = 3)

messydates documentation built on Dec. 3, 2026, 5:09 p.m.