Description Usage Arguments Value Note See Also Examples
Sums elements of a given vector by a given key.
1 | key.sum(v, u)
|
v |
vector to be summed |
u |
vector of non-negative integers indicating how values of |
A vector obtained by summing values of v
by the key u
.
It is intended that: length(v) != sum(u) but otherwise function computes its value vector as well.
function key.sum
is part of function period.loss
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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.