Re: [R] code for "permutative" operation

2011-03-14 Thread nblarson
You mean like cumsum()? > a<-1:10 > b<-cumsum(a) > b [1] 1 3 6 10 15 21 28 36 45 55 -Nick Larson -- View this message in context: http://r.789695.n4.nabble.com/code-for-permutative-operation-tp3354839p3354849.html Sent from the R help mailing list archive at Nabble.com. __

Re: [R] code for "permutative" operation

2011-03-14 Thread David Winsemius
On Mar 14, 2011, at 4:16 PM, Sascha Vieweg wrote: On 11-03-14 21:09, David Winsemius wrote: On Mar 14, 2011, at 3:52 PM, Sascha Vieweg wrote: Hello, I need some form of a "permutative" operation on a numeric vector x x = (v1, v2, v3, ..., vN) that produces x.r = (v1, v1+2, v1+v2+v3, ... v

Re: [R] code for "permutative" operation

2011-03-14 Thread Sascha Vieweg
On 11-03-14 21:09, David Winsemius wrote: On Mar 14, 2011, at 3:52 PM, Sascha Vieweg wrote: Hello, I need some form of a "permutative" operation on a numeric vector x x = (v1, v2, v3, ..., vN) that produces x.r = (v1, v1+2, v1+v2+v3, ... v1+v2+...+vN) If the operation is sum() I can run x

Re: [R] code for "permutative" operation

2011-03-14 Thread David Winsemius
On Mar 14, 2011, at 3:52 PM, Sascha Vieweg wrote: Hello, I need some form of a "permutative" operation on a numeric vector x x = (v1, v2, v3, ..., vN) that produces x.r = (v1, v1+2, v1+v2+v3, ... v1+v2+...+vN) If the operation is sum() I can run x <- 5:8 m <- matrix(rep(x, length(x)), nc

[R] code for "permutative" operation

2011-03-14 Thread Sascha Vieweg
Hello, I need some form of a "permutative" operation on a numeric vector x x = (v1, v2, v3, ..., vN) that produces x.r = (v1, v1+2, v1+v2+v3, ... v1+v2+...+vN) If the operation is sum() I can run x <- 5:8 m <- matrix(rep(x, length(x)), ncol=length(x)) (x.r <- rowsum(m * upper.tri(m, diag=TRU