Suppose we have the following data frame and we wish to find the maximum of column 'value' up to each row, i.e. the resulting new column should be c(4993, 4993, 5036, 5036, 5036)
. Of course I can write a loop for this, but just wondering is there a simple dplyr solution as loops can get tedious to read?
> myDf[1:5, ]
time value
1 2018-01-03 4993
2 2018-01-15 52
3 2018-08-02 5036
4 2018-08-17 -162
5 2018-09-05 4806
Many thanks!