cumSumGroup: Grouped cumulative sums

Description Usage Arguments Details Author(s) See Also Examples

View source: R/cumSumGroup.R

Description

Computes cumulative sums for each set of consecutively identical group levels.

Usage

1

Arguments

x

Vector with doubles that should be cumulatively summed.

group

Vector with integers that identify group levels.

Details

Assumes that all entries, affiliated to a particular group level, are consecutive.

Author(s)

Kjetil R<c3><b8>ysland <[email protected]>

See Also

ave

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (x, group) 
{
    if (length(x) != length(group)) 
        stop("Length of x and group differs")
    r <- .C("cumSumGroup", w = as.double(x), as.integer(length(x)), 
        as.integer(group))
    return(r$w)
  }

kjetilroysland/ahw documentation built on May 18, 2017, 8:40 p.m.