R: Pretty Breakpoints for Date-Time Classes

pretty.Date {grDevices} | R Documentation

## Pretty Breakpoints for Date-Time Classes

### Description

Compute a sequence of about `n+1` equally spaced ‘nice’ values which cover the range of the values in `x`.

### Usage

    ## S3 method for class 'Date'
    pretty(x, n = 5, min.n = n %/% 2, sep = " ", ...)
    ## S3 method for class 'POSIXt'
    pretty(x, n = 5, min.n = n %/% 2, sep = " ", ...)

### Arguments

`x` | an object of class `"Date"` or `"POSIXt"` (i.e., `"POSIXct"` or `"POSIXlt"`).
`n` | integer giving the desired number of intervals.
`min.n` | nonnegative integer giving the minimal number of intervals.
`sep` | character string, serving as a separator for certain formats (e.g., between month and year).
`...` | further arguments for compatibility with the generic, ignored.

### Value

A vector (of the suitable class) of locations, with attribute `"labels"` giving corresponding formatted character labels.

### See Also

`pretty` for the default method.

### Examples

    steps <-
        list("10 secs", "1 min", "5 mins", "30 mins", "6 hours", "12 hours",
             "1 DSTday", "2 weeks", "1 month", "6 months", "1 year",
             "10 years", "50 years", "1000 years")

    names(steps) <- paste("span =", unlist(steps))

    x <- as.POSIXct("2002-02-02 02:02")
    lapply(steps,
           function(s) {
               at <- pretty(seq(x, by = s, length = 2), n = 5)
               attr(at, "labels")
           })

[Package grDevices version 2.15.1 Index]