Hi Amol,
It depends on your exact needs, but one way, assuming you do not need
to access previous calculations, only previous elements:
x <- 1:10
x[-10] / x[-1]
The idea is first create a vector, x, then using negative indices,
select the first 9 elements of x (i.e., 1:9) to be divded by the las
Hi,
I'm a newbie when it comes to R, and I'm trying to figure out how to use
vectorization as opposed to for loops. In particular, how can I create a
function that is applied on each element of a row, but can access previous
elements relative to that element?
My problem: I want to calculate some
2 matches
Mail list logo