"TimeInstantDataFrame"
Class to hold time data that ARE 'instantaneous'.
TimeInstantDataFrame(when, timezone = "UTC", data = NULL, sort=FALSE, ...) as.TimeInstantDataFrame(from, ...)
# S3 method for TimeIntervalDataFrame
as.TimeInstantDataFrame(from, cursor = NULL, ...)
RegularTimeInstantDataFrame(from, to, by, timezone = "UTC", data = NULL)
# S4 method for TimeInstantDataFrame
$(x, name)
# S4 method for TimeInstantDataFrame
$(x, name) <- value
# S3 method for TimeInstantDataFrame
[(x, i, j, drop=FALSE)
# S3 method for TimeInstantDataFrame
[(x, i, j) <- value
# S4 method for TimeInstantDataFrame
[[(x ,i, j, ...)
# S3 method for TimeInstantDataFrame
[[(x, i, j) <- value
# S3 method for TimeInstantDataFrame
rbind(...)
# S3 method for TimeInstantDataFrame
merge(x, y, by, all=TRUE, tz='UTC', sort=TRUE, ...)
# S3 method for TimeInstantDataFrame
split(x, f, drop=FALSE, ...)
# S4 method for TimeInstantDataFrame
lapply(X, FUN, ...)
# S4 method for TimeInstantDataFrame
regular(x, ...)
# S4 method for TimeInstantDataFrame
timezone(object)
# S4 method for TimeInstantDataFrame
timezone(object) <- value
# S4 method for TimeInstantDataFrame
when(x, ...)
# S4 method for TimeInstantDataFrame
dim(x)
# S4 method for TimeInstantDataFrame
length(x)
# S4 method for TimeInstantDataFrame
names(x)
# S4 method for TimeInstantDataFrame
names(x) <- value
# S4 method for TimeInstantDataFrame
ncol(x)
# S4 method for TimeInstantDataFrame
nrow(x)
# S3 method for TimeInstantDataFrame
row.names(x)
# S3 method for TimeInstantDataFrame
row.names(x) <- value
# S3 method for TimeInstantDataFrame
print(x, tz=NULL, ...)
# S3 method for TimeInstantDataFrame
summary(object, ...)
# S3 method for TimeInstantDataFrame
head(x, tz, ...)
# S3 method for TimeInstantDataFrame
tail(x, tz, ...)
# S4 method for TimeInstantDataFrame
show(object)
# S3 method for TimeInstantDataFrame
plot(x, y=NULL, type="p",
lty=1:6, lwd=1, pch=1:25, col=NULL,
xlim=NULL, ylim=NULL, log, main, sub, xlab, ylab,
ann=par("ann"), axes=TRUE, asp=NA, ...)
# S3 method for TimeInstantDataFrame
points(x, y=NULL, type="p",
lty=1:6, lwd=1, pch=1:25, col=NULL, ...)
# S3 method for TimeInstantDataFrame
lines(x, y=NULL, type="l",
lty=1:6, lwd=1, pch=1:25, col=NULL, ...)
# S3 method for TimeInstantDataFrame
barplot(height, format='', ...)
POSIXct or character representing a time with a valid format (see
POSIXct
). It gives the instant of each
row.
character representing a valid timezone (see
timezone
).
a data.frame with as much rows as needed for the created object. Can
be NULL
(hence the data.frame has zero column and as much rows
as needed).
object to convert to a TimeInstantDataFrame
POSIXct or character representing a time with a valid format (see
POSIXct
). It represents the start of the
object.
To convert TimeIntervalDataFrame,
it indicates where the TimeInstant
must be taken. If 0
, start of each intervals is taken as
instant ; if 1
end of each intervals is taken as instant.
Any other value will determine a weigthed instant between start and
end (actually, value higher than 1 or lower than 0 will give instant
outside this range).
POSIXct or character representing a time with a valid format (see
POSIXct
). It represents the end of the
object. If missing, its value is deduced from ‘from’,
‘by’ and ‘data’.
a POSIXctp
object indicating
the increment to use between instants of the object.
specifications of the columns used for merging.
TimeInstantDataFrame object (to modify, to extract or to test)
indices specifying elements to extract or replace. (See
Extract
)
indices specifying elements to extract or replace. (See
Extract
)
A litteral character string or a name. (See
Extract
)
Used for compatibility with data.frame methods.
New value for the object designated (data.frame, names, row.names, etc.).
TimeInstantDataFrame to merge with x
logical; see merge
character representing a valid timezone (see
timezone
).
logical; if TRUE the resulting built/merged TimeInstantDataFrame is ordered according to 'when' values.
a 'factor' in the sense that ‘as.factor(f)’ defines the
grouping, or a list of such factors in which case their
interaction is used for the grouping. See split
.
a TimeInstantDataFrame on which the FUN must be applied.
function to apply over eahc columns of X.
TimeInstantDataFrame object (to modify, to extract or to test)
plotting argument, see plot.default
plotting argument, see plot.default
plotting argument, see plot.default
plotting argument, see plot.default
plotting argument, see plot.default
plotting argument, see plot.default
plotting argument, see plot.default
plotting argument, see plot.default
plotting argument, see plot.default
plotting argument, see plot.default
plotting argument, see plot.default
plotting argument, see plot.default
plotting argument, see plot.default
plotting argument, see plot.default
plotting argument, see plot.default
plotting argument, see barplot
plotting argument, see barplot
More arguments.
Formally, the class consists of a data.frame
and, for each row, a POSIXct
.
This class is provided to deal with punctual time data. Many
of such classes are defined in other packages. This one is defined
mainly to provide a ‘punctual’ class compatible
with TimeIntervalDataFrame
and SubtimeDataFrame
.
The construction of the class allows to manipulate objects as if they were data.frame (see ‘Access to data’ and ‘Access to data properties’).
instant
:Object of class "POSIXct"
corresponding to
the instant of each row of the data.frame
.
timezone
:Object of class "character"
indicating the
timezone of data both for representation and calculation.
data
:Object of class "data.frame"
data contained by
the object.
Objects can be created by calls of the form
new("TimeInstantDataFrame", ...)
... argument must be replaced
by named arguments coresponding to slots of a TimeInstantDataFrame (see below).
See also new
.
TimeInstantDataFrame (when, timezone='UTC', data=NULL, ...)
Arguments of the function correspond to object slots.
RegularTimeInstantDataFrame (from, to, by, timezone='UTC', data=NULL)
, Wrapper to construct TimeInstantDataFrame with specific properties. Instants
of the TimeInstantDataFrame go from 'from' to 'to' regularly spaced by
'by', which is a POSIXctp
or an object which can be coerced to.
as.TimeInstantDataFrame (from, ...)
Converting object to
TimeInstantDataFrame.
Every functions defined in the Ops group (see Ops
)
can be used width a TimeInstantDataFrame and numeric :
tidf * 2
2 * tidf
2:10 == tidf
2^tidf
tidf^2
The TimeInstantDataFrame class is defined to works like the data.frame class
with the difference that a time instant (POSIXct
) is
attached to each rows of the data.frame. Thus to access and manipulate
data of a TimeInstantDataFrame the following methods are defined :
'$', '$<-', '[', '[<-', '[[', '[[<-'. See Extract
for
details.
With ‘[’ operator, a selection by dates is also available. If ‘i’ and or ‘j’ are POSIXt or strings that can be converted to POSIXct (see below), they are considered as the minimal and maximal time limits : all datas between those are selected. A string that can be converted to a POSIXct is (in this case only) a string composed of 3 parts separated by white space : 'YYYY-MM-DD HH:MM:SS tz'. The second and third parts are options, thus accepted format are :
'YYYY-MM-DD'
'YYYY-MM-DD tz'
'YYYY-MM-DD HH:MM:SS'
'YYYY-MM-DD HH:MM:SS tz'
. If timezone is not given, it is assumed to be the same as the one of the object on which the selection is done.
Other methods have been defined to allow some operations over TimeInstantDataFrame :
rbind and merge to join two (or more)
TimeInstantDataFrame (see rbind
and
merge
),
a TimeInstantDataFrame can be splitted exactly the same way that
a data.frame can (see split
in the base
package),
a function can be applied over each column of a TimeInstantDataFrame
via the lapply function. If the function returns one value,
the resulting value is a TimeIntervalDataFrame
beginning at the first instant of the object and ending at the latest one ;
else if the function returns as much values as the number of rows of
the object, the TimeInstantDataFrame given in argument is returned with
the new calculated values ; on others cases, a non-TimeInstantDataFrame
object is returned.
Because a TimeInstantDataFrame works more or less like a data.frame,
the following methods work on a TimeInstantDataFrame :
dim
,
length
,
names
,
names<-
,
ncol
,
nrow
,
row.names
,
row.names<-
.
A TimeInstantDataFrame can be tested for a few time properties :
TRUE if all time instants are equally spaced ;
gives or sets the timezone of the TimeInstantDataFrame ;
returns a POSIXct object with the time instant of the TimeInstantDataFrame.
TimeIntervalDataFrame
, SubtimeDataFrame
showClass("TimeInstantDataFrame")
Run the code above in your browser using DataLab