Skip to content
Prev 306134 / 398506 Next

serial subtraction within a vector

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.