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