Skip to content

serial subtraction within a vector

5 messages · Hermann Norpois, Jorge I Velez, Rui Barradas +2 more

#
Hello,

Try diff(v)

Hope this helps,

Rui Barradas
Em 24-09-2012 12:00, Hermann Norpois escreveu:
#
Hi

I suppose you want

diff(v)

Regards
Petr
#
Hi,

#Just to add:
?v<-c(3,5,8,4,9)
?diff(v)
#[1]? 2? 3 -4? 5
#if it is a dataframe,
v1<-as.data.frame(v)
?lapply(v1,diff)
apply(v1,2,diff)

A.K.




----- Original Message -----
From: Jorge I Velez <jorgeivanvelez at gmail.com>
To: Hermann Norpois <hnorpois at googlemail.com>
Cc: r-help at r-project.org
Sent: Monday, September 24, 2012 8:19 AM
Subject: Re: [R] serial subtraction within a vector

?diff

HTH,
Jorge.-
On Mon, Sep 24, 2012 at 9:00 PM, Hermann Norpois <hnorpois at googlemail.com>wrote:

            
??? [[alternative HTML version deleted]]

______________________________________________
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.