key.sum: Function summing by a given key

Description Usage Arguments Value Note See Also Examples

Description

Sums elements of a given vector by a given key.

Usage

1
key.sum(v, u)

Arguments

v

vector to be summed

u

vector of non-negative integers indicating how values of v should be summed

Value

A vector obtained by summing values of v by the key u.

Note

It is intended that: length(v) != sum(u) but otherwise function computes its value vector as well.

See Also

function key.sum is part of function period.loss

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# the first example:

v <- c(0,1,2,3.4,2)
u <- c(2,2,0,1)

key.sum(v,u)

# the second example:

v1 <- c(0,1,2,3.4,2)
u1 <- c(2,2,0)

key.sum(v1,u1) # of course there is not enough u data to have v1[5] accounted in the value vector

# the third example:

v2 <- c(0,1,2,3.4)
u2 <- c(2,2,0,1)

key.sum(v2,u2) # of course there is not enough v2 data to sum by u2

barryrowlingson/opVaR documentation built on May 11, 2019, 7:24 p.m.