Description Usage Arguments Objects from the Class Slots Accessing to POSIXctp properties Manipulating POSIXctp Text representation Testing two POSIXctp Mathematical operations on POSIXctp Changing class See Also Examples
Class that defines 'periods of time' objects such as 'one month', 'two months', 'three hours', 'four minutes', 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
POSIXctp(duration, unit) as.POSIXctp(from, ...) ## S3 method for class 'POSIXctp' x[i, ...] ## S3 replacement method for class 'POSIXctp' x[i] <- value ## S3 method for class 'POSIXctp' c(...) ## S3 method for class 'POSIXctp' split(x, f, drop=FALSE, ...) ## S3 method for class 'POSIXctp' rep(x, ...) ## S3 method for class 'POSIXctp' unique(x, incomparables=FALSE, ...) ## S4 method for signature 'POSIXctp' unit(x, ...) ## S4 replacement method for signature 'POSIXctp' unit(object) <- value ## S4 method for signature 'POSIXctp' duration(x, ...) ## S4 method for signature 'POSIXctp' length(x) ## S3 method for class 'POSIXctp' print(x, ...) ## S3 method for class 'POSIXctp' format(x, ...) ## S3 method for class 'POSIXctp' summary(object, ...) ## S3 method for class 'POSIXctp' head(x, ...) ## S3 method for class 'POSIXctp' tail(x, ...) ## S4 method for signature 'POSIXctp' show(object) ## S4 method for signature 'POSIXctp,POSIXctp' match(x, table, nomatch = NA_integer_, incomparables=NULL) ## S4 method for signature 'POSIXctp,ANY' match(x, table, nomatch = NA_integer_, incomparables=NULL) ## S4 method for signature 'POSIXctp,ANY' x %in% table ## S3 method for class 'POSIXctp' Ops(e1, e2) ## S4 method for signature 'numeric,POSIXctp' e1 * e2 ## S4 method for signature 'POSIXctp,numeric' e1 * e2 ## S4 method for signature 'POSIXctp,POSIXctp' e1 + e2 ## S4 method for signature 'POSIXctp,POSIXctp' e1 - e2 ## S4 method for signature 'POSIXct,POSIXctp' e1 + e2 ## S4 method for signature 'POSIXctp,POSIXct' e1 + e2 ## S4 method for signature 'POSIXct,POSIXctp' e1 - e2 ## S4 method for signature 'POSIXctp' as.numeric(x, ...)
A vector of factors defined by
Object to convert to a period of time (actually works only for
Argument specific to the split method. See
The values (
The value to be returned i nthe case when no match is found.
A vector of values that cannot be matched.
Objects of this class are used to represent periods of times such
as ‘one hour’, ‘two seconds’, ‘three years’, etc.
Partial periods of time are not allowed (‘1.5 hours’ will be coerced
to an integer value using
POSIXctp (‘p’ stands for‘period’) has only one unit. So ‘one hour and 2 seconds’ is not defined.
One object is actually a vector of periods of time and so can have a length of one for a single period of time or a length of ‘n’ for ‘n’ periods of time.
integer corresponding to the length of the period.
factor indicating the time unit
of the period. See
POSIXt.units to know available
A POSIXctp has several properties. Because a POSIXctp is a vector of
periodes of time, the class has a
length function. Other
properties are time properties :
duration allow to access to the corresponding properties.
duration of a period of time is an integer corresponding of the
time that the period last, in its time unit. The unit of a period of time
is an ordered factor as the one defined by
POSIXctp can be converted to another time unit base (for instance
2 hours make 120 minutes). For that purpose the function
defined. The conversion will be effective only if the new unit can be exactly
defined as a multiple of the old one
(‘hour’ to ‘second’, ok ; ‘year’ to ‘month’, ok
; ‘month’ to ‘minute’ , NOT ok ; etc.
When conversion can not be done, the result has its unit unchanged.
POSIXctp means acting on
POSIXctps like on classical
vectors. Methods available for this task allow to extract or replace parts of
POSIXctp (with the usual '[' operator), and to
c) or split
unique and a
method are defined to uniquify or repeat elements of a
%in% methods have also been
defined to find
POSIXctp objects among others.
To represent a
POSIXctp available functions are
The five first functions work the same way that their generic definition.
POSIXctp are formatted by pasting their duration (
with their unit (and with an ‘s’ if relevant).
To test two POSIXctp 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. For a single comparison, first elements are converted into the same unit. If this is not possible, FALSE is returned if the test is ‘==’, TRUE if the test is ‘!=’, NA otherwise (elements can not be compared) ; else durations of elements are compared and the result of this comparison is returned.
POSIXctp can be added (or substracted) to differents type of objects :
POSIXcti and to
POSIXctp can also be multiplied by
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.
Basic mathematical operation for
POSIXctp are (negative periods of
time can be defined !!) :
integer * POSIXctp
POSIXctp * integer
POSIXctp + POSIXctp
POSIXctp - POSIxctp
POSIXctps do not have the same unit, an attempt is made to convert
one to the unit of the other, if it successes the operation is done otherwise
NA is returned.
Mathematical operations with
are actually time lagging. A
POSIXct to which a
added is lagged by the time periods indicated ; for a
and end are lagged by the time periods.
POSIXst, units of the
POSIXst must be identical : 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).
POSIXct + POSIXctp
POSIXctp + POISXct
POSIXct - POSIXctp
POSIXcti + POSIXctp
POSIXctp + POISXcti
POSIXcti - POSIXctp
POSIXst + POSIXctp
POSIXctp + POISXst
POSIXst - POSIXctp
POSIXctp can be converted to
numeric with the
method. The duration of the object is returned.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.