Re: [R] Replace for loop when vector calling itself

From: rivercode <>
Date: Mon, 07 Mar 2011 12:44:58 -0800 (PST)


Thanks for your replies.

In summary:

  1. Replace code with c(0, cumsum(diff(theoP)) ). This is indeed correct and I had not realized it !!

>> d = vector(mode = "numeric", length= len)
>> d[1] = 0
>> if (len>1) for (i in 2:len) { d[i] = d[i-1] + theoP[i] - theoP[i-1] }

2. How to create recursive vector, eg. vector = previous vector * new_data ... suggested to look at the filter() function.

Thanks for your replies.


View this message in context:
Sent from the R help mailing list archive at

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Tue 08 Mar 2011 - 05:15:03 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 08 Mar 2011 - 05:20:19 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive