Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

pretty_dates

Computes attractive axis breaks for date-time data


Description

pretty.dates indentifies which unit of time the sub-intervals should be measured in to provide approximately n breaks. It then chooses a "pretty" length for the sub-intervals and sets start and endpoints that 1) span the entire range of the data, and 2) allow the breaks to occur on important date-times (i.e. on the hour, on the first of the month, etc.)

Usage

pretty_dates(x, n, ...)

Arguments

x

a vector of POSIXct, POSIXlt, Date, or chron date-time objects

n

integer value of the desired number of breaks

...

additional arguments to pass to function

Value

a vector of date-times that can be used as axis tick marks or bin breaks

Examples

x <- seq.Date(as.Date("2009-08-02"), by = "year", length.out = 2)
pretty_dates(x, 12)

lubridate

Make Dealing with Dates a Little Easier

v1.7.10
GPL (>= 2)
Authors
Vitalie Spinu [aut, cre], Garrett Grolemund [aut], Hadley Wickham [aut], Ian Lyttle [ctb], Imanuel Costigan [ctb], Jason Law [ctb], Doug Mitarotonda [ctb], Joseph Larmarange [ctb], Jonathan Boiser [ctb], Chel Hee Lee [ctb], Google Inc. [ctb, cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.