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

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

1 | ```
period.sum(x, INDEX)
``` |

`x` |
a univariate data object |

`INDEX` |
a numeric vector of endpoints to calculate sum on |

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`

.

An `xts`

or `zoo`

object of sums,
indexed by the period endpoints.

Jeffrey A. Ryan

`endpoints`

, `period.max`

,
`period.min`

, `period.prod`

1 2 3 4 5 | ```
period.sum(c(1,1,4,2,2,6,7,8,-1,20),c(0,3,5,8,10))
data(sample_matrix)
period.sum(sample_matrix[,1],endpoints(sample_matrix))
period.sum(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
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
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.