Reputation: 1112
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
Upvotes: 1
Views: 10285
Reputation: 93803
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")
Upvotes: 3