Home > database >  I am looking for a way to turn intervals into absolute timepoints? [duplicate]
I am looking for a way to turn intervals into absolute timepoints? [duplicate]

Time:09-30

I have list of intervals between events but I need to turn them into a list of timepoints of the same events. Is there a way of adding up values continuously from one column to the other ? Results should like a little something like the table below. Right now only column Interval exists.

Interval Timepoint
0.55 0.55
0.87 1.42
0.80 2.23
0.75 2.98
0.73 3.72
0.64 4.37

CodePudding user response:

The cumsum() function does exactly this!

df = data.frame( interval = interval, time = cumsum(interval) )
  •  Tags:  
  • r
  • Related