Re: [R] R-help? how to take difference in next two elements

2008-08-11 Thread dott
Thanks all for the help, that is done. Gabor Grothendieck wrote: > > Here are a couple of ways: > >> tail(a, -2) - head(a, -2) > [1] 2 5 -3 >> c(ts(a) - lag(ts(a), -2)) > [1] 2 5 -3 > > > On Mon, Aug 11, 2008 at 11:26 AM, dott <[EMAIL PROTECTED]&g

[R] how can I do this sum?

2008-08-11 Thread dott
Hi, Suppose I have a vector in real number (x1, x2, x3, x4, x5, x6) My question is how I can get x5*x3*x1 + x6*x4*x2 ? Thanks a lot. Dot. -- View this message in context: http://www.nabble.com/how-can-I-do-this-sum--tp18931693p18931693.html Sent from the R help mailing list archive at Nabbl

Re: [R] how can I do this sum?

2008-08-11 Thread dott
Matlab has .*, so that t(x1,x2).*t(x3,x4).* t(x5,x6) but what is .* in R? Thanks. Dot. -- View this message in context: http://www.nabble.com/how-can-I-do-this-sum--tp18931693p18932274.html Sent from the R help mailing list archive at Nabble.com.

[R] R-help? how to take difference in next two elements

2008-08-11 Thread dott
Hi, I'd like to take difference for a sequence a between a_i and a_i-2, for instance, a<-c(2,3,4,8,1) I need (2, 5, -3) as a result. If not using a for loop, can anyone help me? Thanks a lot. Dot -- View this message in context: http://www.nabble.com/R-help--how-to-take-difference-in-next-two-