Learn R Programming

timetools (version 1.5.2)

TimeIntervalDataFrame: Create a TimeIntervalDataFrame from scratch

Description

To see all methods related to this class, see TimeIntervalDataFrame-class

Usage

TimeIntervalDataFrame(start, end = NULL,
    timezone = "UTC", data = NULL, period = NULL, ...)

Arguments

start
POSIXct or character representing a time with a valid format (see POSIXct). It gives the begining of each interval.
end
POSIXct or character representing a time with a valid format (see POSIXct). It gives the end of each interval. If NULL, see Details.
timezone
character representing a valid timezone (see timezone).
data
a data.frame with as much rows as the length of start and end, or with one row less than the length of start if end is NULL. Can be NULL (hence the data.frame has zero colu
period
if not NULL, a POSIXctp or a character that can be converted to a POSIXctp (see argument unit of POSIXctp function). See Details to
...
arguments to or from other methods

Value

Details

If both start and end are given, they must have the same length. They are used to define the intervals of the object. If data is also given, it must have a number of rows identical to the length of start and end.

If only start is given, a continuous (see continuous) TimeIntervalDataFrame is built. The first element of start is the start of the first interval, the second element is the end of the first interval and the start of the second interval. The last element of start is only the end of the last interval. This is why data, if given, must be one row shorter than start.

If period is given it must be a POSIXctp object (or a valid character) and start and end must have length equal to 1. In that case, a TimeIntervalDataFrame will be created with start date equal to start floored by the unit of period, end date ceiled by the unit of period and with enough intervals of period length to fit. If data given, it must have a number of rows equal to the number of intervals calculated.

To access to the class documentation, type in the R console :

class?TimeIntervalDataFrame

See Also

TimeInstantDataFrame, RegularTimeIntervalDataFrame, timetools

Examples

Run this code
TimeIntervalDataFrame (
	c('2010-01-01', '2010-02-01'), c('2010-02-01', '2010-02-02'),
	'UTC', data.frame(ex=1:2) )

TimeIntervalDataFrame (
	c('2010-01-01', '2010-02-01', '2010-02-02'), NULL,
	'UTC', data.frame(ex=1:2) )

TimeIntervalDataFrame(
	as.POSIXct('2013-01-01'), as.POSIXct('2013-03-01'),
	period=POSIXctp('day')
)

Run the code above in your browser using DataLab