period.prod: Calculate Product By Period

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Calculate a product for each period of INDEX. Essentially a rolling application of prod over a series of non-overlapping sections.

Usage

1
period.prod(x, INDEX)

Arguments

x

a univariate data object

INDEX

a vector of breakpoints to calculate product on

Details

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.

Value

An xts or zoo object of products, indexed by the period endpoints.

Author(s)

Jeffrey A. Ryan

See Also

endpoints, period.sum, period.min, period.max

Examples

1
2
3
4
5

Example output

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

xts documentation built on Sept. 13, 2020, 5:09 p.m.