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

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

Hi,

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.

Cheers,
Chris

--
View this message in context: http://r.789695.n4.nabble.com/Replace-for-loop-when-vector-calling-itself-tp3338383p3339938.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
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 https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive