Assume I have the following df:
df <- data.frame(day = c(1:8), value= c(10, 25, NA, 7, NA, NA, 20, NA))
    Day     Value
1     1        10
2     2        25
3     3        NA
4     4         7
5     5        NA
6     6        NA
7     7        20
8     8        NA
I'm looking for a solution to replace NA in 'Value' column with the most recent previous non-NA value. The desired output will be:
    Day     Value
1     1        10
2     2        25
3     3        25
4     4         7
5     5         7
6     6         7
7     7        20
8     8        20
 
     
    