cumsum_g.Rd
Compute per-group cumulative sums
cumsum_g(col, first_indices, na.rm = FALSE)
col | vector to cumulative sum |
---|---|
first_indices | numeric index of first index in each group |
na.rm | locial if TRUE remove NAs (empty sum is zero). |
per-group cumulative sum
v <- c(2, 3, 1, NA, 5) fi <- c(1, 1, 3, 3, 3) cumsum_g(v, fi)#> [1] 2 5 1 NA NA