如何计算累计金额? [英] How to calculate cumulative sum?
本文介绍了如何计算累计金额?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有包含 biweek
和 Total
列的数据,我想获取 biweek
的累积总和.我的数据就像:
I have data containing columns biweek
and Total
, I want to get cumulative sum on biweek
basis. My data is like:
biweek Total
0 3060.913
1 4394.163
2 3413.748
3 2917.548
4 3442.055
5 3348.398
6 1771.722
我想得到像这样的输出:
and I want to get output like :
biweek Total
0 3060.913
1 7455.076
2 10868.824
3 13786.372
4 17228.427
5 20576.825
6 22348.547
那么有可能实现它吗?
推荐答案
# replace the second column for the cumsum of the initial second column
data[, 2] <- cumsum(data[, 2])
这篇关于如何计算累计金额?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文