Enhanced Cumulative Sum Calculation
hsaCumsum.RdComputes cumulative sums with options for handling missing values (NA), including linear interpolation between existing values.
Value
Numeric vector of cumulative sums with same length as x:
NAs at start/end remain after warning
Interpolated values for internal NAs when na.action="interpolate"
Details
For na.action="interpolate":
Uses linear interpolation via stats::approx()
Leading/trailing NAs are set to 0 with warning
Returns NA for positions where input was NA
See also
approx for interpolation method
Examples
x <- c(1, 2, NA, 4, 5, NA, 7)
# With interpolation
hsaCumsum(x)
#> [1] 1 3 6 10 15 21 28
# With NA replacement
hsaCumsum(x, na.action=0)
#> [1] 1 3 3 7 12 12 19