| align {dtts} | R Documentation |
Align a data.table onto a nanotime vector
Description
align returns the subset of data.table x that
aligns on the temporal vector y
Usage
align(x, y, start, end, ...)
## S4 method for signature 'data.table,nanotime,nanoduration,nanoduration'
align(
x,
y,
start = as.nanoduration(0),
end = as.nanoduration(0),
sopen = FALSE,
eopen = TRUE,
func = NULL
)
## S4 method for signature 'data.table,nanotime,missing,missing'
align(
x,
y,
start = as.nanoduration(0),
end = as.nanoduration(0),
sopen = FALSE,
eopen = TRUE,
func = NULL
)
## S4 method for signature 'data.table,nanotime,nanoduration,missing'
align(
x,
y,
start = as.nanoduration(0),
end = as.nanoduration(0),
sopen = FALSE,
eopen = TRUE,
func = NULL
)
## S4 method for signature 'data.table,nanotime,missing,nanoduration'
align(
x,
y,
start = as.nanoduration(0),
end = as.nanoduration(0),
sopen = FALSE,
eopen = TRUE,
func = NULL
)
## S4 method for signature 'data.table,nanotime,nanoperiod,nanoperiod'
align(
x,
y,
start = as.nanoperiod(0),
end = as.nanoperiod(0),
sopen = FALSE,
eopen = TRUE,
tz,
func = NULL
)
## S4 method for signature 'data.table,nanotime,nanoperiod,missing'
align(
x,
y,
start = as.nanoperiod(0),
end = as.nanoperiod(0),
sopen = FALSE,
eopen = TRUE,
tz,
func = NULL
)
## S4 method for signature 'data.table,nanotime,missing,nanoperiod'
align(
x,
y,
start = as.nanoperiod(0),
end = as.nanoperiod(0),
sopen = FALSE,
eopen = TRUE,
tz,
func = NULL
)
Arguments
x |
the |
y |
the |
start |
scalar or vector of same length as |
end |
scalar or vector of same length as |
... |
further arguments passed to or from methods. |
sopen |
boolean scalar or vector of same lengths as |
eopen |
boolean scalar or vector of same lengths as |
func |
a function taking one argument and which provides an
arbitrary aggregation of its argument; if |
tz |
scalar or vector of same length as |
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
## Not run:
y <- nanotime((1:10)*1e9)
x <- data.table(index=nanotime((1:10)*1e9), data=1:10)
align(x, y, as.nanoduration(-1e9), as.nanoduration(1e9), colMeans)
## End(Not run)