frequency-data.table-method: Return the number of observations per interval

Description Usage Arguments Details Value Examples

Description

frequency returns the number of observations in data.table x when subdivided in the specified interval

Usage

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

Arguments

x

the data.table time-series for which to calculate the frequency

by

interval specified in nanoseconds

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

The interval specified in by is used to subdivide x. The number of observations in x is then counted for each interval, and the results are assigned to the end of each interval.

Value

a data.table time-series with the number of observations in x that fall withing the intervals defined by by

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)
frequency(x, as.integer64(one_minute))

## End(Not run)

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