1

Is there a cumulative graph package in R? Or how might I create a cumulative graph in R? For example, given values of 2, 4, 2, 2, they values should be plotted as 2, 6, 8, 10 d3 example here. Then forming a stair step pattern as with other cumulative records

Community
  • 1
  • 1
d-cubed
  • 1,034
  • 5
  • 30
  • 58

1 Answers1

3

As per ?plot.default - there is a "stairs" plotting method, which can be combined with cumsum() to give the result you want I think:

plot(cumsum(c(2,4,2,2)), type="s")

enter image description here

thelatemail
  • 91,185
  • 12
  • 128
  • 188