POSIXcti {timetools} | R Documentation |
Class "POSIXcti"
Description
S4 class that defines 'time interval' objects.
Usage
POSIXcti(start, end, timezone='UTC', ...)
as.POSIXcti(from, ...)
## S3 method for class 'POSIXcti'
x[i, ...]
## S3 replacement method for class 'POSIXcti'
x[i] <- value
## S3 method for class 'POSIXcti'
c(...)
## S3 method for class 'POSIXcti'
split(x, f, drop=FALSE, ...)
## S3 method for class 'POSIXcti'
rep(x, ...)
## S3 method for class 'POSIXcti'
unique(x, incomparables=FALSE, ...)
## S3 method for class 'POSIXcti'
i1 %intersect% i2
## S3 method for class 'POSIXcti'
start(x, ...)
## S3 method for class 'POSIXcti'
end(x, ...)
## S4 method for signature 'POSIXcti'
duration(x, ...)
## S4 method for signature 'POSIXcti'
length(x)
## S3 method for class 'POSIXcti'
print(x, ...)
## S3 method for class 'POSIXcti'
format(x, format = "%Y-%m-%d %H:%M:%S", ...)
## S3 method for class 'POSIXcti'
summary(object, ...)
## S3 method for class 'POSIXcti'
head(x, ...)
## S3 method for class 'POSIXcti'
tail(x, ...)
## S4 method for signature 'POSIXcti'
show(object)
## S4 method for signature 'POSIXcti,POSIXcti'
match(x, table, nomatch = NA_integer_, incomparables=NULL)
## S4 method for signature 'POSIXcti,POSIXcti'
x %in% table
## S3 method for class 'POSIXcti'
Ops(e1, e2)
## S3 method for class 'POSIXcti'
i1 %included% i2
## S4 method for signature 'POSIXcti,POSIXctp'
e1 + e2
## S4 method for signature 'POSIXctp,POSIXcti'
e1 + e2
## S4 method for signature 'POSIXcti,POSIXctp'
e1 - e2
Arguments
start |
|
end |
|
timezone |
|
from |
Object to convert to a time interval (actually works only for
|
x |
|
i |
index ( |
value |
New |
f |
|
drop |
Argument specific to the split method. See |
format |
|
object |
|
table |
The values ( |
nomatch |
The value to be returned i nthe case when no match is found.
See |
incomparables |
A vector of values that cannot be matched.
See |
e1 |
For (<, <=, !=, ==, >=, >) |
e2 |
For (<, <=, !=, ==, >=, >) |
i1 |
|
i2 |
|
... |
More arguments. |
Objects from the Class
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.
Slots
start
:Object of class
"POSIXct"
corresponding to the beginning of the interval.duration
:integer indicating in seconds the duration of intervals.
Accessing to POSIXcti properties
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
Manipulating POSIXcti
means acting on POSIXcti
s 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
.
Text representation
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.
Testing two POSIXcti
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 :
- e1 < e2
TRUE if
end(e1) <= start(e2)
.- e1 <= e2
TRUE if
start(e1) <= start(e2) & end(e1) <= end(e2)
.- e1 != e2
TRUE if
start(e1) != start(e2) | duration(e1) != duration(e2)
.- e1 == e2
TRUE if
start(e1) == start(e2) & duration(e1) == duration(e2)
.- e1 >= e2
TRUE if
start(e1) >= start(e2) & end(e1) >= end(e2)
.- e1 > e2
TRUE if
end(e1) >= start(e2)
.- i1 %included% i2
TRUE if
start(i1) >= start(i2) & end(i1) <= end(i2)
.
Mathematical operations on POSIXcti
‘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
See Also
POSIXct
, TimeIntervalDataFrame
,
POSIXst
, POSIXctp
Examples
# 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