Please use R's help resources before posting. help.search("difference") will give you your answer (?diff).
-- Bert Gunter Genentech -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of dott Sent: Monday, August 11, 2008 8:27 AM To: r-help@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@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. ______________________________________________ R-help@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.