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
Video Tutorial: Compute & Plot the Cumulative Sum in R
![YouTube](https://data-hacks.com/wp-content/plugins/borlabs-cookie/assets/images/cb-no-thumbnail.png)
By loading the video, you agree to YouTube’s privacy policy.
Learn more