如何在 R 中创建累积图

How to create a cumulative graph in R

R有累积图包吗?或者我如何在 R 中创建累积图? 例如,给定值 2、4、2、2,它们的值应绘制为 2、6、8、10 . Then forming a stair step pattern as with other cumulative records

根据 ?plot.default - 有一个 "stairs" 绘图方法,它可以与 cumsum() 结合使用以给出您想要的结果我认为:

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