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

Bert Gunter gunter.berton at gene.com
Mon Aug 11 21:18:18 CEST 2008


Please use R's help resources before posting.

help.search("difference") will give you your answer (?diff).

-- Bert Gunter
Genentech 

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of dott
Sent: Monday, August 11, 2008 8:27 AM
To: r-help at r-project.org
Subject: [R] R-help? how to take difference in next two elements


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

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list