Adding values in a row to the previous one in R

r, row

Solution

Try something like

L <- 100 + cumsum(K)

Problem

I would like to perform a simple operation in R that is easily done in excel: I have a col consisting of 5045 entries called K. I would like to create a second col L where the first value is L1=100+K[1] the second is L2=L1+K[2], the third is L3=L2+K[3] and so on. Is there a simple way to do this in R? in Excel one just has to pull down the col.

Original source