How to calculate cumulative sum? [duplicate]

# replace the second column for the cumsum of the initial second column
data[, 2] <- cumsum(data[, 2])

Leave a Comment