Re: [R] Modifying the embed-results

2006-08-27 Thread Gabor Grothendieck
On 8/27/06, Atte Tenkanen <[EMAIL PROTECTED]> wrote: > Thanks! > I see, that do.call-function is used often in R-algorithms... Looking over > some extra do.call-examples seems useful. This tail-function is also new for > me. > > Is there some reason to use seq(along = VECTOR) instead of 1:length

Re: [R] Modifying the embed-results

2006-08-26 Thread Atte Tenkanen
Thanks! I see, that do.call-function is used often in R-algorithms... Looking over some extra do.call-examples seems useful. This tail-function is also new for me. Is there some reason to use seq(along = VECTOR) instead of 1:length(VECTOR)? Atte > You can replace the for with lapply like thi

Re: [R] Modifying the embed-results

2006-08-26 Thread Gabor Grothendieck
You can replace the for with lapply like this: VECTOR <- c(0, 3, 6, 3, 11, 2, 11, 4, 3, 4, 7, 7, 6, 4, 8) f <- function(i) unique(tail(VECTOR, length(VECTOR)-i+1))[1:5] out <- do.call(rbind, lapply(seq(along = VECTOR), f)) na.omit(rbind(rep(NA, 5), out)) Note that a matrix with zero rows is retu

Re: [R] Modifying the embed-results

2006-08-25 Thread Atte Tenkanen
Again my example was't very clear: there were not enough same numbers in the VECTOR. What I need is something like this: VECTOR<-c(0,3,6,3,11,2,11,4,3,4,7,7,6,4,8) MATRIX<-c() for(i in 1:length(VECTOR)){ v<-(unique(VECTOR[i:length(VECTOR)])[1:5]) MATRIX<-rbind(MATRIX,v) } MATRIX<

Re: [R] Modifying the embed-results

2006-08-25 Thread Gabor Grothendieck
Try: embed(VECTOR, 5)[,5:1] On 8/25/06, Atte Tenkanen <[EMAIL PROTECTED]> wrote: > Hi, > > Here is a vector and the result from the embed-command: > > VECTOR=c(0,3,6,3,11,2,4,3,7,6,4,5,10,2,3,5,8) > > > embed(VECTOR, dimension=5) > [,1] [,2] [,3] [,4] [,5] > [1,] 113630 >

[R] Modifying the embed-results

2006-08-25 Thread Atte Tenkanen
Hi, Here is a vector and the result from the embed-command: VECTOR=c(0,3,6,3,11,2,4,3,7,6,4,5,10,2,3,5,8) > embed(VECTOR, dimension=5) [,1] [,2] [,3] [,4] [,5] [1,] 113630 [2,]2 11363 [3,]42 1136 [4,]342 113 [5,]