Scaled-cummulative sums

Description

Cummulative sums of a vector are scaled on a constant value.

Usage

1
scacum(x, y = NA, z = NA)

Arguments

x

numeric vector with vector names being ordered on time

y

NA or numeric constant to scale the vector. If NA then the cummulative sums are not scaled.

z

NA or numeric constant in range of the vector names. If NA then maximun value in such a range is used.

Details

Cummulative values of the numeric vector are computed with cumsum

Value

data frame with the original vector, and its scaled-cummulative sums.

Author(s)

Wilson Lara <wilarhen@gmail.com>, Felipe Bravo <fbravo@pvs.uva.es>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
x <- c(0.79,0.32,0.53,0.43,0.18)
names(x) <- 1948:1952
y <- 4
z <- 1951
scacum(x,y,z)

##If y = NA then cummulative values are scaled arround
##max(cumsum(x)):
max(cumsum(x))
scacum(x,NA)