"POSIXst"
Class to define POSIXst object such as hours of day, seconds of year, etc.
POSIXst(x, unit, of = NULL, tz = "UTC", ...)
# S3 method for default
POSIXst (x, unit, of = NULL, tz = "UTC", ...)
# S3 method for integer
POSIXst (x, unit, of = NULL, tz = "UTC", ...)
# S3 method for numeric
POSIXst (x, unit, of = NULL, tz = "UTC", ...)
# S3 method for POSIXct
POSIXst (x, unit, of = NULL, tz = attributes(x)$tzone, ...)
# S3 method for POSIXlt
POSIXst (x, unit, of = NULL, tz = attributes(x)$tzone, ...)
# S3 method for TimeInstantDataFrame
POSIXst (x, unit, of = NULL, tz = timezone(x), ...)
# S3 method for TimeIntervalDataFrame
POSIXst (x, unit, of = NULL, tz = timezone(x), ..., cursor = NULL)year(x, ...)
month(x, ...)
day(x, of, ...)
hour(x, of, ...)
minute(x, of, ...)
second(x, of, ...)
# S3 method for POSIXst
[(x, i)
# S3 method for POSIXst
[(x, i) <- value
# S3 method for POSIXst
c(...)
# S3 method for POSIXst
split(x, f, drop=FALSE, ...)
# S3 method for POSIXst
rep(x, ...)
# S3 method for POSIXst
seq(from, to, ...)
# S3 method for POSIXst
unique(x, incomparables=FALSE, ...)
# S3 method for POSIXst
duplicated(x, incomparables=FALSE, ...)
# S3 method for POSIXst
unit(x, ...)
# S3 method for POSIXst
of(x, ...)
# S3 method for POSIXst
timezone(object)
# S4 method for POSIXst
length(x)
# S3 method for POSIXst
print(x, ...)
# S3 method for POSIXst
format(x, format, ...)
# S3 method for POSIXst
summary(object, ...)
# S3 method for POSIXst
head(x, ...)
# S3 method for POSIXst
tail(x, ...)
# S4 method for POSIXst
show(object)
# S4 method for POSIXst,POSIXst
match(x, table, nomatch = NA_integer_, incomparables=NULL)
# S4 method for POSIXst,ANY
match(x, table, nomatch = NA_integer_, incomparables=NULL)
# S4 method for POSIXst,ANY
%in%(x, table)
# S3 method for POSIXst
Ops(e1, e2)
# S4 method for POSIXst,POSIXctp
+(e1, e2)
# S4 method for POSIXctp,POSIXst
+(e1, e2)
# S4 method for POSIXst,POSIXctp
-(e1, e2)
# S4 method for POSIXst,POSIXst
-(e1, e2)
# S4 method for POSIXst
as.numeric(x, ...)
object to convert into POSIXst or POSIXst
object on which the
method has to be applied.
indicates the subtime part to extract ('year', 'month', 'day', 'hour', 'minute', 'second')
used to specify the main period from wich the is to extract ('year', 'month', day', 'hour', 'minute'). Not used for ‘unit in c('year', 'month')’.
if needed, specifies th timezone of POSIXst
for TimeIntervalDataFrame, if not NULL, the object is first
coerced to a TimeInstantDataFrame using the
as.TimeInstantDataFrame
method.
index (logical
or numeric
) of the POSIXst objects.
New POSIXst
object.
factor
used to group the POSIXst
elements.
Argument specific to the split method. See link[base]{split}
documentation.
POSIXst
object on which the method has to be applied.
Character string to precise the desired format. See section ‘Text representation’ below for details.
The values (POSIXst
) 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.
POSIXst
or POSIXctp
. See details.
POSIXst
or POSIXctp
. See details.
starting and end values to sequence, see seq
More arguments.
Objects of this class are used to represent subtimes. A subtime (or a ‘POSIXst’, ‘st’ stand for Sub and Time) is a subdivision of time :
second of a minute ;
second of an hour ;
second of a day ;
second of a week ;
second of a month ;
second of a year ;
minute of an hour ;
minute of a day ;
...
minute of a year ;
...
month of year ;
year AD (after death).
A POSIXst is a kind of time object composed of 2 units and
a positionnal integer.
The main unit can be accessed via the ‘of’ function ;
the sub unit can be accessed via the ‘unit’ function.
The positionnal integer correspond to the value of the subtime object.
Consequently, a subtime st
is the value
th unit(st)
of of(st)
.
The range of valid values for each kind of POSIXst is defined accordingly
to the DateTimeClasses
definitions. For instance
valid values for seconds of hour are 0 to 61, valid values for
day of week are 0 to 6, etc.
To define POSIXst objects see POSIXst section below.
One object is actually a vector of subtimes and so can have a length of one for a single subtime or a length of ‘n’ for ‘n’ subtimes.
Last, a POSIXst object has a ‘timezone’ slots. This is defined
for compatibility reason with POSIXct object and also with
TimeInstantDataFrame
, TimeIntervalDataFrame
and
SubtimeDataFrame
.
subtime
:Object of class "integer"
corresponding to the
actual value of each subtime.
unit
:factor representing a time unit. It represents the
subdvision of time (in 'second of year' it corresponds to 'second').
See POSIXt.units
.
of
:factor representing a time unit. It represents the main
time unit (in 'second of year' it corresponds to 'year'). See
POSIXt.units
.
timezone
:Object of class "character"
indicating the
timezone of the POSIXst object.
POSIXst
objects can be created from various other class objects.
For this purpose the POSIXst
method has been defined.
First, if ‘x’ is missing, an empty factor with the appropriated levels (according to ‘unit and of’) is returned.
A POSIXst
can be created from an integer or a numeric. If so,
‘unit’
and ‘of’ msute be supplied (see arguments section above). The ‘tz’
argument can be supplied (numeric will be converted to an integer). In both
cases, values of the integer/numeric must be in the right range
(see DateTimeClasses
.
A POSIXst
can be created from a POSIXct
or
POSIXlt
object. In this case, the subtime (POSIxst) is extracted
in the units indicated by ‘unit’ and ‘of’ arguments. The
‘tz’ argument indicates the timezone of the resulting object (it doesn't
do any conversion on the POSIXl,ct objects).
Finally, POSIXst
can be extracted from TimeInstantDataFrame
and TimeIntervalDataFrame
. For the first type of object, the
method is applied to the time instants (which are POSIXct
). For the
latter, because a time interval can contains several POSIXst of one kind (for
instance a day contains all 'hours of day'), the result of this method
TimeIntervalDataFrame is a list of POSIXst. Each element of the list contains
the POSIXsts asked for corresponding to each row of the TimeIntervalDataFrame
object. If ‘cursor’ is supplied, the TimeIntervalDataFrame is first
converted to a TimeInstantDataFrame (see as.TimeInstantDataFrame
for details).
year
, month
, day
, hour
, minute
and
second
are methods defined to extract the adequat information from a
time object. These functions are wrappers to POSIXst
.
Each of these methods call POSIXst replacing the unit
argument with its
own name :
minute(x, of='day')
will call
POSIXst(x, unit='minute', of='day')
A POSIXst has several properties. Because a POSIXst is a vector of
subtimes, the class has a length
function. Other
properties are time properties : unit
, of
and timezone
allow to access to the corresponding properties.
The ‘unit’ and ‘of’ of a subtime
is an ordered factor as the one defined by POSIXt.units
.
For more informations on timezone, see the page of the manual.
Manipulating POSIXst
means acting on POSIXst
s like on classical
vectors. Methods available for this task allow to extract or replace parts of
a POSIXst
(with the usual '[' operator), and to
concatenate (c
) or split POSIXst
(split
). A unique
, a duplicated
, a rep
and a seq
methods are defined to uniquify, repeat or sequence elements of a POSIXst
.
match
and %in%
methods have also been
defined to find POSIXst
objects among others.
To represent a POSIXst
available functions are print
,
summary
, head
,
tail
, show
and format
.
The five first functions work the same way that their generic definition.
'POSIXst' are formatted according to the format
argument which must
respect the following rules.
%v value
%s subtime unit (slot ‘unit’)
%m main unit (slot ‘of’)
%a Abbreviated weekday name in the current locale.
%A Full weekday name in the current locale.
%b Abbreviated month name in the current locale.
%B Full month name in the current locale.
%r timezone
%p place of subtime (ie the string part of 1st, 2nd, 10th, etc.)
To test two POSIXst the differents operators of comparison are used.
If the POSIXst
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. Two POSIXst
with a different
‘unit’ or a different ‘of’ are differents (TRUE if test is
‘!=’, FALSE if ‘==’ NA otherwise). If they have identical
‘unit’ and ‘of’ the comparison is made over subtime slots.
POSIXst
can be added and substracted to POSIXctp
.
POSIXst
can also be substracted (and only substracted) to POSIXst
.
For all operations, if the two arguments 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.
Mathematical operations with POSIXctp
are actually time lagging. Units
of the POSIXctp
must be identical to the POSIXst
's : the object
is then lagged by the time periods (if the result is higher than the maximum
the result is recycled at the begining. For instance :
saturday + 2 days = monday
).
POSIXst + POSIXctp
POSIXctp + POISXst
POSIXst - POSIXctp
Substracting a POSIXst
to another result in a POSIXctp
.
For instance wednesday - monday = 2 days
.
POSIXst
can be converted to numeric
with the as.numeric
method. The subtime slot of the object is returned.
POSIXct
, POSIXcti
, POSIXctp
,
TimeIntervalDataFrame
,