【发布时间】:2015-09-10 12:27:16
【问题描述】:
我想对一个字段进行累积求和,但每当遇到 0 时都会重置聚合值。
这是我想要的一个例子:
data.frame(campaign = letters[1:4] ,
date=c("jan","feb","march","april"),
b = c(1,0,1,1) ,
whatiwant = c(1,0,1,2)
)
campaign date b whatiwant
1 a jan 1 1
2 b feb 0 0
3 c march 1 1
4 d april 1 2
【问题讨论】:
-
this question I asked a couple of weeks ago 的答案应该可以帮助您解决这个问题。
标签: r