title: What's the R equivalent of Stata's _n function?
body: <p>I am wondering whether there is a function in R like in Stata, where you are able to use the value of the observation n numbers before or after each observation. For instance if I need to multiply or divide with the observation before I would write something like this <code>variable_x/variable_x[_n-1]</code></p>