"POSIXcti"S4 class that defines 'time interval' objects.
POSIXcti(start, end, timezone='UTC', ...)
as.POSIXcti(from, ...) # S3 method for POSIXcti
[(x, i, ...)
# S3 method for POSIXcti
[(x, i) <- value
# S3 method for POSIXcti
c(...)
# S3 method for POSIXcti
split(x, f, drop=FALSE, ...)
# S3 method for POSIXcti
rep(x, ...)
# S3 method for POSIXcti
unique(x, incomparables=FALSE, ...)
# S3 method for POSIXcti
%intersect%(i1, i2)
# S3 method for POSIXcti
start(x, ...)
# S3 method for POSIXcti
end(x, ...)
# S4 method for POSIXcti
duration(x, ...)
# S4 method for POSIXcti
length(x)
# S3 method for POSIXcti
print(x, ...)
# S3 method for POSIXcti
format(x, format = "%Y-%m-%d %H:%M:%S", ...)
# S3 method for POSIXcti
summary(object, ...)
# S3 method for POSIXcti
head(x, ...)
# S3 method for POSIXcti
tail(x, ...)
# S4 method for POSIXcti
show(object)
# S4 method for POSIXcti,POSIXcti
match(x, table, nomatch = NA_integer_, incomparables=NULL)
# S4 method for POSIXcti,POSIXcti
%in%(x, table)
# S3 method for POSIXcti
Ops(e1, e2)
# S3 method for POSIXcti
%included%(i1, i2)
# S4 method for POSIXcti,POSIXctp
+(e1, e2)
# S4 method for POSIXctp,POSIXcti
+(e1, e2)
# S4 method for POSIXcti,POSIXctp
-(e1, e2)
POSIXct object indicating the beginning of the time
interval.
POSIXct object indicating the end of the time interval.
character indicating the timezone in which the time
interval is set. See timezone.
Object to convert to a time interval (actually works only for
NA).
POSIXcti object on which the method has to be applied.
index (logical or numeric) of the time interval objects.
New POSIXcti object.
factor used to group the POSIXcti elements.
Argument specific to the split method. See link[base]{split}
documentation.
character indicating the format to use to represent
the time interval. See sectopn ‘Text representation’ below
for further details.
POSIXcti object on which the method has to be applied.
The values (POSIXcti vector) to be matched against. See
match for further details.
The value to be returned i nthe case when no match is found.
See match for further details.
A vector of values that cannot be matched.
See match for further details.
For (<, <=, !=, ==, >=, >) POSIXcti to compare ; otherwise
a POSIXcti to shift by a time period (POSIXctp) or
a POSIXctp by which a POSIXcti has to be shift.
For (<, <=, !=, ==, >=, >) POSIXcti to compare ; otherwise
a POSIXcti to shift by a time period (POSIXctp) or
a POSIXctp by which a POSIXcti has to be shift.
POSIXcti to test/intersect. See %included% and
%intersect% for further details.
POSIXcti to test/intersect. See %included% and
%intersect% for further details.
More arguments.
Objects of this class represent time intervals. One object is actually a vector of time intervals and so can have a length of one for a single time interval or a length of ‘n’ for ‘n’ time intervals.
start:Object of class "POSIXct" corresponding to the
beginning of the interval.
duration:integer indicating in seconds the duration of intervals.
A POSIXcti has several properties. Because a POSIXcti is a vector of
time intervals, the class has a length function. Other
properties are time properties : start, end
and duration allow to access to the corresponding properties.
The duration of a time interval is the number of seconds for which
the interval last.
Manipulating POSIXcti means acting on POSIXctis like on classical
vectors. Methods available for this task allow to extract or replace parts of
a POSIXcti (with the usual '[' operator), and to
concatenate (c) or split POSIXcti
(split). A unique and a rep
method are defined to uniquify or repeat elements of a POSIXcti.
match and %in% methods have also been
defined to find POSIXctp objects among others.
Last, the %intersect% method allow to intersect two
POSIXcti.
To represent a POSIXcti available functions are print,
summary, head,
tail, show and format.
The five first functions work the same way that their generic definition.
POSIXcti are formatted by pasting the character strings
representing both start and end of each intervals.
Start and end's format can be specified with the format
argument according to the basic format.POSIXct function.
To test two POSIXcti the differents operators of comparison are used. One
more is defined : %included%. If the POSIXcti compared
have a different length, the shorter is recycled over the longer so the
resulting vector (a logical vector) has length equal to the longer object.
Comparisons are made element by element. The result for a single comparison is given there :
TRUE if end(e1) <= start(e2).
TRUE if start(e1) <= start(e2) & end(e1) <= end(e2).
TRUE if start(e1) != start(e2) | duration(e1) != duration(e2).
TRUE if start(e1) == start(e2) & duration(e1) == duration(e2).
TRUE if start(e1) >= start(e2) & end(e1) >= end(e2).
TRUE if end(e1) >= start(e2).
TRUE if start(i1) >= start(i2) & end(i1) <= end(i2).
‘Mathematical’ operations are actually ‘time lagging’ for
POSIXcti. A
time period is added/removed to both start and end
of intervals. The available operations are :
POSIXcti + POSIXctp
POSIXctp + POISXcti
POSIXcti - POSIXctp
POSIXct, TimeIntervalDataFrame,
POSIXst, POSIXctp
# time interval : january of year 2013
jan <- POSIXcti('2013-01-01', '2013-02-01')
jan
# the complete year
y2013 <- POSIXcti('2013-01-01', '2014-01-01')
y2013
# is jan in 2013 ?
jan %included% y2013
# intersection
jan %intersect% y2013
Run the code above in your browser using DataLab