I am trying to calculate the log returns of a dataset in R using the usual log differencing method. However, the calculated data is simply a vector of zeroes. I can't see what I'm doing wrong.
Here is the snippet showing what I'm doing
> prices <- data$cl
> head(prices)
[1] 1108.1 1095.4 1095.4 1102.2 1096.3 1096.7
>
>
> lrets <- log(lag(prices)) - log(prices)
> head(lrets)
[1] 0 0 0 0 0 0
> summary(lrets)
Min. 1st Qu. Median Mean 3rd Qu. Max.
0 0 0 0 0 0
What am I doing wrong?