Re: [R] Counting the loop-round of a "for"-loop

2012-02-13 Thread 538280
Consider using sapply instead of a for loop, if the code in the sapply call returns a vector, and every vector is the same length, then sapply will automatically form it into a matrix for you. On Sun, Feb 12, 2012 at 12:30 PM, jolo999 wrote: > It seems to work. Simple and effective! > > Thanks! >

Re: [R] Counting the loop-round of a "for"-loop

2012-02-12 Thread jolo999
It seems to work. Simple and effective! Thanks! -- View this message in context: http://r.789695.n4.nabble.com/Counting-the-loop-round-of-a-for-loop-tp4381319p4381780.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.or

Re: [R] Counting the loop-round of a "for"-loop

2012-02-12 Thread Ista Zahn
Hi, You can initialize a counter and update it in the loop. An silly example (unrelated to yours because it was not reproducible) of this technique is: x <- matrix( , ncol = 2, nrow = 26) n <- 0 for(i in letters) { n <- n+1 x[n,] <- c(i, n) } Best, Ista On Sunday, February 12, 2012 07:

[R] Counting the loop-round of a "for"-loop

2012-02-12 Thread jolo999
Dear all, i have daily stock prices for more than 10 years and want to compute annual volatilities for certain dates during this period. Since i have found no "easy" way to work with time data, the data presents itself in the structure TIme Index - Stock Price 1 - 15,6 2 - 17 ... ... 2010 - 28 2