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

dott dorothy99 at gmail.com
Mon Aug 11 17:26:39 CEST 2008


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-elements-tp18927968p18927968.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list