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

Calculate Cumulative Sum with cumsum() Function

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

Video Tutorial: Compute & Plot the Cumulative Sum in R

YouTube

By loading the video, you agree to YouTube’s privacy policy.
Learn more

Load video

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top