I am new to R coding and I am trying to model the returns on the ftse100 since 1990. I have got a vector with all the closing values on each trading day. however, instead of using the difference in the closing values of two consecutive days, (ie dx=diff(x) where x is the vector containing the closing values), i wanted to use the quotient of the two closing values. I have tried the following without any luck
> for (i in 2:n) {
+ dx[i]=(d[i])/(d[i-1])
+ delta=dx[i]
+ }
where n=length(x).
the vecotr x contains about 5900 values.
how do i do this in R please.