Description Usage Arguments Details Value Author(s) See Also Examples
Calculate a product for each period of INDEX. Essentially a rolling application of prod over a series of non-overlapping sections.
1 | period.prod(x, INDEX)
|
x |
a univariate data object |
INDEX |
a vector of breakpoints to calculate product on |
Used to calculate a product per period given an arbitrary index of sections to be calculated over. This is an optimized function for product. There are additionally optimized versions for min, max, and sum.
For xts-coercible objects, an appropriate INDEX can be
derived from a call to endpoints
.
An xts
or zoo
object of products,
indexed by the period endpoints.
Jeffrey A. Ryan
endpoints
, period.sum
,
period.min
, period.max
1 2 3 4 5 | period.prod(c(1,1,4,2,2,6,7,8,-1,20),c(0,3,5,8,10))
data(sample_matrix)
period.prod(sample_matrix[,1],endpoints(sample_matrix))
period.prod(as.xts(sample_matrix)[,1],endpoints(sample_matrix))
|
Loading required package: zoo
Attaching package: 'zoo'
The following objects are masked from 'package:base':
as.Date, as.Date.numeric
3 5 8 10
4 4 336 -20
30 58 89 119 150 180
1.056649e+51 5.757944e+47 3.468070e+52 7.433317e+50 1.608181e+52 1.969971e+50
[,1]
2007-01-31 1.056649e+51
2007-02-28 5.757944e+47
2007-03-31 3.468070e+52
2007-04-30 7.433317e+50
2007-05-31 1.608181e+52
2007-06-30 1.969971e+50
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.