pretty: Pretty Breakpoints for Time Indices

prettyR Documentation

Pretty Breakpoints for Time Indices

Description

Determine locations of pretty breakpoints for time indices. pretty method for objects of tind class employs separate algorithms for each type / resolution, see Details.

Usage

## S3 method for class 'tind'
pretty(x, n = 5L, min.n = n%/%2L, ...)

Arguments

x

an object of tind class.

n

an integer value giving the expected number of intervals.

min.n

an integer value giving the minimal number of intervals.

...

(ignored) further arguments passed to or from other methods

Details

Resolution of ticks (see resolution_t method) is always the same or lower than the resolution of the argument and lower resolutions have to be multiples of the resolution of the argument. This way, the ticks are never placed, for example, every 5 years for indices with a 2-year resolution.

For years, the tics are placed at powers of 10 times 1, 2, or 5.

For quarters, ticks are placed every quarter, every second quarter (1st and 3rd), or on first the quarters of years selected by separate procedure for years.

For months, ticks are placed every 1, 2, 3, 4, 6 months or on January of years selected by the separate procedure for years.

For weeks, ticks are placed every 1, 2, 4, 13, 26 weeks or on the first weeks of years selected by the separate procedure for years.

For dates, depending on the number of observations, ticks can be placed:

  • every day,

  • every Monday, Wednesday, and Friday,

  • every Monday and Thursday,

  • every Monday,

  • every 1st and 16th day of a month,

  • on 1st days of months selected by the separate procedure for months.

For date-time and time of day, the placement of ticks depends on the resolution of indices. When all indices are at full hours, ticks are placed at full hours only. Similar approach is taken for minutes and seconds. Divisors of 24 are used for hours and divisors of 60 for minutes and seconds. For date-time indices spanning more than a couple of days, ticks are placed on midnights of days selected by the separate procedure for dates.

Due to the design of the algorithm, in some corner cases (esp. for time of day and weeks) the number of intervals might differ significantly from the expected number n.

Value

An object of tind class.

See Also

resolution_t method, axis_t for computing time axis parameters for plotting, axis.tind for creating axes with graphics package, scale_tind for creating axes with ggplot2.

Examples

(td <- tind(y = sample(2010:2018, 4, replace = TRUE),
            m = sample(1:12, 4, replace = TRUE),
            d = sample(1:2, 4, replace = TRUE)))
pretty(td)
pretty(td, 3)
pretty(td, 10)
(th <- tind(H = sample(0:23, 4, replace = TRUE),
            M = sample(0:3 * 15, 4, replace = TRUE)))
pretty(th)
pretty(th, 3)
pretty(th, 10)
(tdt <- date_time(td[1], th))
pretty(tdt)
pretty(tdt, 3)
pretty(tdt, 10)


tind documentation built on Dec. 28, 2025, 1:06 a.m.