ops {dtts} | R Documentation |
Arithmetic operations on two data.table
time-series
Description
ops
returns the y
time-series on which the x
time-series values are applied using the specified operator
op
.
Usage
ops(x, y, op_string)
## S4 method for signature 'data.table,data.table,character'
ops(x, y, op_string)
Arguments
x |
the |
y |
the |
op_string |
string defining the operation to apply; the
supported values for |
Details
The n elements of the x
time-series operand define a set of
n-1 intervals, and the value associated with each interval is
applied to all the observations in the y
time-series
operand that fall in the interval. Note that the interval is
closed at the beginning and open at the end. The supported values
for op
are "*", "/", "+", "-".
There has to be one numeric column in x
and y
; there
has to be either a one to one correspondance between the number of
numeric columns in x
and y
, or there must be only
one numeric column in x
that will be applied to all numeric
columns in y
. Non-numeric columns must not appear in
x
, whereas they will be skipped of they appear in y
.
Examples
## Not run:
one_second_duration <- as.nanoduration("00:00:01")
t1 <- nanotime(1:2 * one_second_duration * 3)
t2 <- nanotime(1:4 * one_second_duration)
dt1 <- data.table(index=t1, data1 = 1:length(t1))
setkey(dt1, index)
dt2 <- data.table(index=t2, data1 = 1:length(t2))
setkey(dt2, index)
ops(dt1, dt2, "+")
## End(Not run)