itsDef {its} | R Documentation |
The function its
is used to create irregular time-series
objects from user-supplied data and time-stamps.
newIts
is used to create semi-regular time-series
objects from user-supplied data, and rule for generating time-stamps.
as.its
coerces an object to an irregularly spaced
time-series. is.its
tests whether an object is an irregularly
spaced time series.
its(x, dates=as.POSIXct(x=strptime(dimnames(x)[[1]],format=its.format())), names=dimnames(x)[[2]], format=its.format(), ...) newIts(x=NA,start=format(Sys.Date(),format=its.format()), end,ncol=1,by="DSTday",extract=FALSE,format=its.format(),tz="",...) as.its(x,...) is.its(object) its.format(formatDefault=NULL)
dates |
a vector of class "POSIXct"
representing the time-stamps of the irregular time-series
object. The elements of the numeric vector are construed as the
number of seconds since the beginning of 1970, see POSIXct . |
start, end |
POSIXct or character representation of the start or end time-stamp,
if character, then the format is as specified by the argument format |
ncol |
number of columns of synthetic sequence of dates |
by |
time increment for synthetic sequence of dates, see seq.POSIXt |
extract |
logical flag: if TRUE, a subset of the synthetic sequence of dates is extracted,
see extractIts |
x |
a numeric matrix representing the values of the
irregular time-series object. In the case of coercion in as.its, the first
column is taken to be the time-stamps, in seconds since the beginning
of 1970, see POSIXct . |
object |
|
names |
a vector of mode character |
format |
a formatting string, see format.POSIXct , defaults to
its.format() |
formatDefault |
a formatting string, see format.POSIXct ,
defaults to "%Y-%m-%d" if formatDefault is not specified. |
tz |
time zone of dates of its object |
... |
further arguments passed to or from other methods:
for its passed to format.POSIXct .;
for as.its passed to its .;
for newIts passed to extractIts . |
The function its
is used to create irregular time-series objects,
which have (S4) class "its". An object of class "its" is a matrix with rows indexed by a time-stamp
of class "POSIXct". Unlike objects of class "ts", it can be used to
represent irregularly spaced time-series. The object consists of a
matrix, with a single slot, the named POSIX vector named "dates".
An object of class "its" inherits matrix arithmetic methods. The matrix
has dimnames: dimnames[[1]] is populated with a text representation of
"dates", using a format which is defined by the function its.format. These
dates are not used in computations - all computations use the
POSIX representation. The dates are required to be in ascending order.
When matrix multiplication is applied to an "its", the result is of class matrix. It is possible to restore the "its" class (see examples) - its() is in this sense idempotent i.e. its(mat)==its(its(mat)). Note however that the dates will be taken from dimnames[[1]], so the accuracy of this operation depends on the format of the dates.
newIts
is a utility for creating a new "its" using a series of 'semi-regular'
time-stamps, such as weekday, weekly, monthend etc. Conceptually the date sequence
generation has two parts. The first part is the generation of a sequence using
seq.POSIXt
- the arguments from, to, and by are passed to this function. The second
part (which is optional, and applies only if extract=TRUE) is an extraction,
performed by extractIts
. See extractIts
for details of the arguments,
which are passed via '...' .
The function its.format
assigns a private variable and returns its value. The
value of this default format persists in the session until reset. The purpose of the
function is one of convenience: to access and/or assign the default text format for dates
in the "its" package, and hence reduce the need to define the format repeatedly in a session.
For its
, newIts
and as.its
, an object of class "its"
, inheriting
from matrix, with a single slot named 'dates'
, which is a vector of class POSIXct
For is.its
, a logical representing the result of a test for class membership
For its.format
, a text representation of dates formatting to be used in the "its" package,
see format.POSIXct
Giles Heywood
ts
,
POSIXct
,
itsFile
,
itsLags
,
itsJoin
,
itsTimes
,
itsSubset
,
itsFin
,
itsDisp
,
itsInfo
,
itsCumdif
,
itsArith
,
itsInterp
its.format("%Y-%m-%d") #defines text format of dates read from dimnames mat <- structure(1:6,dim=c(2,3),dimnames=list(c("2003-01-01","2003-01-04"),letters[1:3])) its(mat) its.format("%Y%m%d") #defines text format of dates written to dimnames times <- as.POSIXct(strptime(c("1999-12-31 01:00:00","2000-01-01 02:00:00"),format="%Y-%m-%d %X")) its(mat,times) its.format("%Y-%m-%d %X") its(mat,times) is.its(its(mat,times)) its.format("%Y%m%d %X") #defines text format of dates written to dimnames as.its(mat) its.format("%a %d %b %Y") newIts(start="2003-09-30",end="2005-05-05",format="%Y-%m-%d",period="month",find="last",extract=TRUE,weekday=TRUE) newIts(start=ISOdate(2003,12,24,0),end=ISOdate(2004,1,10),extract=TRUE,weekday=TRUE) its.format("%Y%m%d") as(newIts(),"data.frame")