📜  r 数据框添加具有累积值的列 - 无论代码示例

📅  最后修改于: 2022-03-11 14:56:10.448000             🧑  作者: Mango

代码示例1
df <- data.frame(id = rep(1:3, each = 5)
                 , hour = rep(1:5, 3)
                 , value = sample(1:15))
                 
df %>% group_by(id) %>% mutate(csum = cumsum(value))