- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# How to create a cumulative sum plot in base R?

To create a cumulative sum plot in base R, we can simply use plot function. For cumulative sums inside the plot, the cumsum function needs to be used for the variable that has to be summed up with cumulation. For example, if we have two vectors say x and y then the plot with cumulative sum plot can be created as plot(x,cumsum(y)).

## Example

x1<--10:10 y1<-rnorm(21,5,0.324) plot(x1,cumsum(y1))

## Output

## Example

x2<-1:20 y2<-rpois(20,5) plot(x2,cumsum(y2))

## Output

- Related Articles
- How to create a perpendicular arrow in base R plot?
- How to create a plot in base R without margins?
- How to create empty bar plot in base R?
- How to create a colored box for base R plot?
- How to create a column in an R data frame with cumulative sum?
- How to create a plot with dashed regression line in base R?
- How to create a Cumulative Sum Column in MySQL?
- How to create a plot with reversed Y-axis labels in base R?
- How to create a vertical line in a time series plot in base R?\n
- How to create a plot in base R with tick marks of larger size?
- How to create a plot in base R with dates sequence on X-axis?
- How to create a base R plot without axes but keeping the frame of the plot?
- How to create cumulative sum chart with count on Y-axis in R using ggplot2?
- How to create a plot in base R with tick marks but excluding axes lines?
- How to create a plot with tick marks between X-axis labels in base R?

Advertisements