I have data like
date price
26-12-2015 112
25-12-2015 115
24-12-2015 119
23-12-2015 NA
22-12-2015 120
I want to calculate daily returns so the syntax using ttr package is
ROC(data$price, type="discrete")
The calculation will be (112-115)-1 and so on but it will show NA for date 23-12-2015.
I want for when NA is present for previous date it should take price of the day before. I don't want to delete that row as I have dataframe with many other prices and I will lose that information.