grid.align-data.table-method: Align a 'data.table' onto a 'nanotime' vector grid

Description Usage Arguments Details Value Examples

Description

grid.align returns the subset of data.table x that aligns on the grid defined by by, start and end

Usage

1
2
3
## S4 method for signature 'data.table'
grid.align(x, by, func, ival = by, start = x[[1]][1],
  end = tail(x[[1]], 1))

Arguments

x

the data.table time-series to align from

by

interval specified in nanoseconds

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.

start

scalar nanotime defining the start of the grid; by default the first element of x is taken.

end

scalar nanotime defining the end of the grid; by default the last element of x is taken.

Details

A grid defined by the parameter by, start and end is created. The function then does a standard alignment of x onto this grid (see the align function)

Value

a data.table time-series of the same length as y with the aggregations computed by func

Examples

1
2
3
4
5
6
7
## Not run: 
one_second <- 1e9
one_minute <- 60 * one_second
x <- data.table(index=nanotime(cumsum(sin(seq(0.001, pi, 0.001)) * one_second)), 1)
grid.align(x, as.integer64(one_minute), sum)

## End(Not run)

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