align: Align a 'data.table' onto a 'nanotime' vector

Description Usage Arguments Details Value Examples

Description

align returns the subset of data.table x that aligns on the temporal vector y

Usage

1
align(x, y, start = as.integer64(0), end = as.integer64(0), func = NULL)

Arguments

x

the data.table time-series to align from

y

the nanotime vector to align to

start

scalar or vector of same length as y of type integer64; start is added to each element in y and it then defines the starting point of the interval under consideration for the alignement on that element of y

end

scalar or vector of same length as y of type integer64; start is added to each element in y and it then defines the ending point of the interval under consideration for the alignement on that element of y

func

a function taking one argument and which provides an arbitrary aggregation of its argument; if NULL then a function which takes the closest observation is used.

Details

For each element in y, intervals are created around this element with start and end. All the elements of x that fall within this interval are given as argument to the function func. The function func show reduce this data.frame to one unique row that will be associated with the nanotime value in y.

Value

a data.table time-series of the same length as y; this is a subset of x with the nanotime index of y

Examples

1
2
3
4
5
6
## Not run: 
y <- nanotime((1:10)*1e9)
x <- data.table(index=nanotime((1:10)*1e9), data=1:10)
align(x, y, as.integer64(-1e9), as.integer64(1e9), colMeans)

## End(Not run)

lsilvest/dtts.utils documentation built on May 15, 2019, 1:42 p.m.