calc_startpoints | R Documentation |
Calculate a vector of start points by lagging (shifting) a vector of end points.
calc_startpoints(endd, lookb)
endd |
An integer vector of end points. |
lookb |
The length of the look-back interval, equal to the lag (shift) applied to the end points. |
The start points are equal to the values of the vector endd
lagged
(shifted) by an amount equal to lookb
. In addition, an extra
value of 1
is added to them, to avoid data overlaps. The lag
operation requires appending a beginning warmup interval containing zeros,
so that the vector of start points has the same length as the endd
.
For example, consider the end points for a vector of length 25
divided into equal intervals of length 5
: 4, 9, 14, 19, 24
.
(In C++
the vector indexing starts at 0
not 1
, so
it's shifted by -1
.)
Then the start points for lookb = 2
are equal to: 0, 0,
5, 10, 15
. The differences between the end points minus the
corresponding start points are equal to 9
, except for the warmup
interval.
An integer vector with the same number of elements as the
vector endd
.
# Calculate end points
endd <- HighFreq::calc_endpoints(length=55, step=5)
# Calculate start points corresponding to the end points
startp <- HighFreq::calc_startpoints(endd, lookb=5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.