period.sum: Calculate Sum By Period

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

Description

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

Usage

1
period.sum(x, INDEX)

Arguments

x

a univariate data object

INDEX

a numeric vector of endpoints to calculate sum on

Details

Used to calculate a sum per period given an arbitrary index of sections to be calculated over. This is an optimized function for sum. There are additionally optimized versions for min, max, and prod.

For xts-coercible objects, an appropriate INDEX can be derived from a call to endpoints.

Value

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

Author(s)

Jeffrey A. Ryan

See Also

endpoints, period.max, period.min, period.prod

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 
 6  4 21 19 
      30       58       89      119      150      180 
1506.342 1421.960 1535.487 1488.806 1497.902 1424.315 
               [,1]
2007-01-31 1506.342
2007-02-28 1421.960
2007-03-31 1535.487
2007-04-30 1488.806
2007-05-31 1497.902
2007-06-30 1424.315

xts documentation built on March 18, 2018, 2:18 p.m.