File: scale.R

package info (click to toggle)
chron 2.3-45-1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 240 kB
  • ctags: 8
  • sloc: ansic: 127; makefile: 1
file content (23 lines) | stat: -rw-r--r-- 653 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
chron_trans <-
function(format = "%Y-%m-%d", n = 5)
{
    breaks. <- function(x)
        chron(scales::pretty_breaks(n)(x))
    format. <- function(x)
        format(as.POSIXct(x, tz = "GMT"), format = format)
    scales::trans_new("chron",
                      transform = as.numeric, inverse = chron,
                      breaks = breaks., format = format.)
}

scale_x_chron <-
function(..., format = "%Y-%m-%d", n = 5)
{
    ggplot2::scale_x_continuous(..., trans = chron_trans(format, n))
}

scale_y_chron <-
function(..., format = "%Y-%m-%d", n = 5)
{
    ggplot2::scale_y_continuous(..., trans = chron_trans(format, n))
}