frequency,data.table-method {dtts} | R Documentation |
Return the number of observations per interval
Description
frequency
returns the number of observations in
data.table
x
for each interval specified by
by
.
Usage
## S4 method for signature 'data.table'
frequency(
x,
by,
grid_start,
grid_end,
tz,
ival_start = -by,
ival_end,
ival_sopen = FALSE,
ival_eopen = TRUE
)
Arguments
x |
the |
by |
interval specified as a |
grid_start |
scalar |
grid_end |
scalar |
tz |
scalar of type character. Only used when the type of
|
ival_start |
scalar of type |
ival_end |
scalar of type |
ival_sopen |
boolean scalar that indicates if the start of the interval is open or closed. Defaults to FALSE. |
ival_eopen |
boolean scalar that indicates if the end of the interval is open or closed. Defaults to TRUE. |
Value
a data.table
time-series with the number of
observations in x
that fall withing the intervals
defined by the grid interval defined by by
.
Examples
## Not run:
one_second <- as.nanoduration("00:00:01")
one_minute <- 60 * one_second
x <- data.table(index=nanotime((1:100) * one_second), 1)
setkey(x, index)
frequency(x, one_minute)
## End(Not run)