r dataframe add a column with cumulative values code example
Example: r dataframe add a column with cumulative values
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))