gendateaxis {plgraphics}R Documentation

Generate a variable expressing time with its attributes for plotting

Description

gendateaxis generates suitable attributes for plotting a date or time variable.
gendate generates a date variable and is an extension of as.POSIXct.

Usage

gendate(date = NULL, year = 2000, month = 1, day = 1, hour = 0, 
  min = 0, sec = 0, data = NULL, format = "y-m-d", origin = NULL)

gendateaxis(date = NULL, year = 2000, month = 1, day = 1, hour = 0,
  min = 0, sec = 0, data = NULL, format = "y-m-d", origin = NULL,
  ploptions=NULL)

Arguments

date

vector of class dates or chron or vector to be converted into such an object. May also be the name of such a variable contained in data. If date has class dates or chron, the arguments year, month and day are ignored.

year, month, day, hour, min, sec

numeric vectors giving the year, month, day of month, hour, minute, second – or the name of such a variable contained in data. day, hour, min, sec can be fractional, see Details. If these arguments are used, the supersede the respective parts in date.

data

data.frame, where variables can be found

format

format for date in case that the latter is a character vector

origin

year of origin for dates, defaults to ploptions("date.origin")

ploptions

list pl options, generated by pl.control

Details

If hour is fractional, e.g., 6.2, the fraction is respected, that is, it will be the same as time 06:12. If min is also given, the fraction of hour is ignored. Similar for day and min.
If hour is >=24, the day is augmented by hour%/%24 and the hour is set to hour%%24. Similar for min and sec.

Value

For gendate, a vector of times in POSIXct format.
For gendateaxis, this is augmented by the attribute

numvalues

numerical values used for plotting. If years, months or days vary in the data, the units are days. Otherwise, they are hours, minutes, or seconds, depending on the highest category that varies.

Unless the dates only cover one of the categories (only years differ, or only months, ...), the following plotting attributes are added:

ticksat

vector where tickmarks are shown. It contains its own attribute small if secondary ticks are suitable.

ticklabels

May be years, quarters, month names, days, ...

ticklabelsat

vecor of coordinates to place the ticklabels

label

equals "", since the time scale makes it clear enough that the axis represents time.

Author(s)

Werner A. Stahel

See Also

genvarattributes, axis.Date

Examples

## call gendateaxis without 'real' data
tt <- gendate(year=rep(2010:2012, each=12), month=rep(1:12, 3))
ta <- gendateaxis(tt)

## ... derived from data
data(d.river)
d.river$dt <- gendateaxis(date="date", hour="hour", data=d.river)
plyx(O2~dt, data=d.river, subset=months(date)!="Sep")
plyx(O2~dt, data=d.river[months(d.river$date)!="Sep",])
plyx(O2~dt, data=d.river, subset=1:1000)

[Package plgraphics version 1.2 Index]