timeSeries (version 4032.109)

colCum: Cumulated column statistics

Description

Functions to compute cumulative column statistics.

Usage

# S4 method for timeSeries
colCumsums(x, na.rm = FALSE, ...)

# S4 method for timeSeries colCummaxs(x, na.rm = FALSE, ...)

# S4 method for timeSeries colCummins(x, na.rm = FALSE, ...)

# S4 method for timeSeries colCumprods(x, na.rm = FALSE, ...)

# S4 method for timeSeries colCumreturns(x, method = c("geometric", "simple"), na.rm = FALSE, ...)

Value

"matrix" for the default methods of all functions,

"timeSeries" for the "timeSeries" methods

Arguments

x

a time series, may be an object of class "matrix", or "timeSeries".

na.rm

a logical. Should missing values be removed?

method

a character string to indicate if geometric (TRUE) or simple (FALSE) returns should be computed.

...

arguments to be passed.

Details

These functions compute the requested cumulative quantities columnwise to obtain a matrix of the same dimension as the data. The "timeSeries" methods replace the data part of the original object with the resulting matrix.

The "timeSeries" methods for the Math group functions cummin, cummax, cumsum, and cumprod, work similarly but don't have the na.rm argument.

See Also

Math,timeSeries-method, rowCumsums

Examples

Run this code
## simulate return data
x <- matrix(rnorm(24), ncol = 2)
X <- as.timeSeries(x)
     
## cumulative sums  by column  -
class(colCumsums(x))  # "matrix"
class(colCumsums(X))  # "timeSeries"

colCumsums(X)

Run the code above in your browser using DataLab