- Related Questions & Answers
- How to create a plot in base R without margins?
- How to create a perpendicular arrow in base R plot?
- How to create empty bar plot in base R?
- 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 add a picture to plot in base R?
- How to rotate text in base R plot?
- How to create a plot in base R with dates sequence on X-axis?
- How to create a plot in base R with tick marks of larger size?
- How to create heatmap in base R?
- How to create a plot with tick marks between X-axis labels in base R?
- How to create a plot in base R with tick marks but excluding axes lines?
- How to create horizontal lines for each bar in a bar plot of base R?

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

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)).

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

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

Advertisements