gendateaxis | R Documentation |
gendateaxis
generates suitable attributes for
plotting a date or time variable.
gendate
generates a date variable and is an extension of
as.POSIXct
.
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)
date |
vector of class |
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 |
data.frame, where variables can be found |
format |
format for |
origin |
year of origin for dates, defaults to
|
ploptions |
list pl options, generated by |
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
.
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 |
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. |
Werner A. Stahel
genvarattributes, axis.Date
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.