Cumulative sum by group in sqldf?

前端 未结 3 825
余生分开走
余生分开走 2020-12-19 23:51

I have a data frame with 3 variables: place, time, and value (P, T, X). I want to create a fourth variable which will be the cumulative sum of X. Normally I like to do group

3条回答
  •  长情又很酷
    2020-12-20 00:24

    I hope i understood what you want:

    library(plyr)
    ddply(df, .(P,T), summarize, cumsum(X))
    

    does this help you?

提交回复
热议问题