period.sum | R Documentation |
Calculate a sum, product, minimum, or maximum for each non-overlapping
period specified by INDEX
.
period.sum(x, INDEX)
period.prod(x, INDEX)
period.max(x, INDEX)
period.min(x, INDEX)
x |
A univariate data object. |
INDEX |
A numeric vector of endpoints for each period. |
These functions are similar to calling period.apply()
with the same
endpoints and function. There may be slight differences in the results due
to numerical accuracy.
For xts-coercible objects, an appropriate INDEX
can be created by a call
to endpoints()
.
An xts or zoo object containing the sum, product, minimum, or
maximum for each endpoint in INDEX
.
Jeffrey A. Ryan
endpoints()
, period.apply()
x <- c(1, 1, 4, 2, 2, 6, 7, 8, -1, 20)
i <- c(0, 3, 5, 8, 10)
period.sum(x, i)
period.prod(x, i)
period.min(x, i)
period.max(x, i)
data(sample_matrix)
y <- sample_matrix[, 1]
ep <- endpoints(sample_matrix)
period.sum(y, ep)
period.sum(as.xts(y), ep)
period.prod(y, ep)
period.prod(as.xts(y), ep)
period.min(y, ep)
period.min(as.xts(y), ep)
period.max(y, ep)
period.max(as.xts(y), ep)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.