# cumsum Function in R (Example)

This tutorial explains how to calculate the cumulative sum with the cumsum() function in the R programming language.

## Example Data

vec <- c(8, 1, 5, 3, 5, 3) # Create example data |

vec <- c(8, 1, 5, 3, 5, 3) # Create example data

## Calculate Cumulative Sum with cumsum() Function

cumsum(vec) # Calculate cumulative sum # 8 9 14 17 22 25 |

cumsum(vec) # Calculate cumulative sum # 8 9 14 17 22 25