Skip to content
Prev 295294 / 398502 Next

Creating functions with a loop.

On May 22, 2012, at 10:06 AM, Etienne Larriv?e-Hardy wrote:

            
There is a cumsum function:

 > cumsum(1:10)
  [1]  1  3  6 10 15 21 28 36 45 55

Did you mean something like?:

  ff.k[j] <- ff.j[j] - sum(1:j),      for j=k-1

In R the paren, "(", indicates that you are calling a function whereas  
you appear interested in making an indexed assignment to a vector.
You may have clear idea about which k-indices should go where in that  
expression, but I surely do not. What are 'x1' and 'x2'?