From this data I want a new column ("from") with the first value for each row of cumulative values. It should actually be the last value from column "cum" + 1. How would you do this with a function? Imagine many rows.
a <- c(5,5,4,3)
cum <- cumsum(a)
df <- data.frame(a,cum)
df
a cum
5 5
5 10
4 14
3 17
df$from <- c(1,6,11,15)
df
a cum from
5 5 1
5 10 6
4 14 11
3 17 15