Description Usage Arguments Objects from the Class Slots POSIXst year(...), month(...), day(...), hour(...), minute(...) and second(...) Accessing to POSIXst properties Manipulating POSIXst Text representation Testing two POSIXst Mathematical operations on POSIXst Changing class See Also Examples
Class to define POSIXst object such as hours of day, seconds of year, etc.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
POSIXst(x, unit, of = NULL, tz = "UTC", ...) ## Default S3 method: POSIXst(x, unit, of = NULL, tz = "UTC", ...) ## S3 method for class 'integer' POSIXst(x, unit, of = NULL, tz = "UTC", ...) ## S3 method for class 'numeric' POSIXst(x, unit, of = NULL, tz = "UTC", ...) ## S3 method for class 'POSIXct' POSIXst(x, unit, of = NULL, tz = attributes(x)$tzone, ...) ## S3 method for class 'POSIXlt' POSIXst(x, unit, of = NULL, tz = attributes(x)$tzone, ...) ## S3 method for class 'TimeInstantDataFrame' POSIXst(x, unit, of = NULL, tz = timezone(x), ...) ## S3 method for class '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 class 'POSIXst' x[i] ## S3 replacement method for class 'POSIXst' x[i] <- value ## S3 method for class 'POSIXst' c(...) ## S3 method for class 'POSIXst' split(x, f, drop=FALSE, ...) ## S3 method for class 'POSIXst' rep(x, ...) ## S3 method for class 'POSIXst' seq(from, to, ...) ## S3 method for class 'POSIXst' unique(x, incomparables=FALSE, ...) ## S3 method for class 'POSIXst' duplicated(x, incomparables=FALSE, ...) ## S3 method for class 'POSIXst' unit(x, ...) ## S3 method for class 'POSIXst' of(x, ...) ## S3 method for class 'POSIXst' timezone(object) ## S4 method for signature 'POSIXst' length(x) ## S3 method for class 'POSIXst' print(x, ...) ## S3 method for class 'POSIXst' format(x, format, ...) ## S3 method for class 'POSIXst' summary(object, ...) ## S3 method for class 'POSIXst' head(x, ...) ## S3 method for class 'POSIXst' tail(x, ...) ## S4 method for signature 'POSIXst' show(object) ## S4 method for signature 'POSIXst,POSIXst' match(x, table, nomatch = NA_integer_, incomparables=NULL) ## S4 method for signature 'POSIXst,ANY' match(x, table, nomatch = NA_integer_, incomparables=NULL) ## S4 method for signature 'POSIXst,ANY' x %in% table ## S3 method for class 'POSIXst' Ops(e1, e2) ## S4 method for signature 'POSIXst,POSIXctp' e1 + e2 ## S4 method for signature 'POSIXctp,POSIXst' e1 + e2 ## S4 method for signature 'POSIXst,POSIXctp' e1 - e2 ## S4 method for signature 'POSIXst,POSIXst' e1 - e2 ## S4 method for signature 'POSIXst' as.numeric(x, ...)
object to convert into POSIXst or
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
Argument specific to the split method. See
Character string to precise the desired format. See section ‘Text representation’ below for details.
The values (
The value to be returned i nthe case when no match is found.
A vector of values that cannot be matched.
starting and end values to sequence, see
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
The range of valid values for each kind of POSIXst is defined accordingly
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
Object of class
"integer" corresponding to the
actual value of each subtime.
factor representing a time unit. It represents the
subdvision of time (in 'second of year' it corresponds to 'second').
factor representing a time unit. It represents the main
time unit (in 'second of year' it corresponds to 'year'). See
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.
POSIXst can be created from an integer or a numeric. If so,
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
POSIXst can be created from a
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).
POSIXst can be extracted from
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
second are methods defined to extract the adequat information from a
time object. These functions are wrappers to
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 :
timezone allow to access to the corresponding properties.
The ‘unit’ and ‘of’ of a subtime
is an ordered factor as the one defined by
For more informations on timezone, see the page of the manual.
POSIXst means acting on
POSIXsts like on classical
vectors. Methods available for this task allow to extract or replace parts of
POSIXst (with the usual '[' operator), and to
c) or split
methods are defined to uniquify, repeat or sequence elements of a
%in% methods have also been
defined to find
POSIXst objects among others.
To represent a
POSIXst available functions are
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.
%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.
%p place of subtime (ie the string part of 1st, 2nd, 10th, etc.)
To test two POSIXst the differents operators of comparison are used.
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
POSIXst can also be substracted (and only substracted) to
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
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
POSIXst to another result in a
wednesday - monday = 2 days.
POSIXst can be converted to
numeric with the
method. The subtime slot of the object is returned.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.