GRtime {GENEAread} | R Documentation |
Date time handling for the GENEAread package.
Description
Stores date time data as a numeric, with facility for pretty printing and axis commands.
Usage
as.GRtime(x, format = NULL, ...)
Arguments
x |
Object to process. For |
format |
A character string indicating the form of output. See |
... |
Additional arguments to be passed to |
Details
The GRtime class handles dates and times for the GENEAread class. The class treats dates as numerics
denoting seconds since the UNIX epoch, with potentially a string attached specifying the format to print in.
Unlike POSIXct
, we avoid some of the processing, especially with respect to time zones, and allow
some more flexibility in time computation and display. A range of operators are defined.
convert.time
converts numerics to GRtime objects. The format
argument allows a format
string to be attached specifying the default format to display in. as.GRtime
is a wrapper to
convert.time
, that when supplied with character input, coerces the value first to numeric using
parse.time
.
format.GRtime
formats GRtime objects for pretty printing. If format
is provided as argument,
that is used. Else, if the format
attribute is set on x
, that is used. Finally, if formats
are not provided, and x
is of length greater than one, the range of values of x
is used to
decide the units displayed. Numerics are also accepted - they are coerced to GRtime.
axis.GRtime
is used to plot GRtime axis, choosing, by default, breakpoints that give 'pretty' sub
intervals. Note that plot.default
uses axis.GRtime
by default if supplied with a
GRtime object in one of the directions. However, image.default
based functions do not use
the class axis functions, so axes must be plotted manually.
pretty.GRtime
computes 'pretty' breakpoints, using the algorithm of pretty.POSIXt
.
Attributes are preserved.
For
convert.time
,as.GRtime
andpretty.GRtime
, a GRtime object.For
format.GRtime
a character string representation.For
axis.GRtime
a list containing positions and labels for axis markers.
See Also
parse.time
, get.intervals
, AccData
Examples
as.GRtime("00:01")
#format is automatically set
convert.time(1:10)
convert.time(1:10*1000)
#we add a different default format
convert.time(1:10*1000, "%H:%M:%OS3") -> t
t
str(t)
# we override format with our own
format(t, format = "%a %d/%m/%y %H:%M:%OS3")
# plot calls axis.GRtime automatically. Notice
# that the format attribute is used.
plot(t, 1:10)
#strip out the default format
t2 = convert.time(t, format = NULL)
plot(t2, 1:10)
# image plots are a bit more complex
Z = matrix(rnorm(100), 10)
image(x = t, y = t2, z = Z, axes = FALSE)
Axis(x = t, side = 1) #Axis also works
box() #complete the bounding box
# custom axes
plot(t2, 1:10, xaxt = "n")