An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120924/412b2a8e/attachment.pl>
serial subtraction within a vector
5 messages · Hermann Norpois, Jorge I Velez, Rui Barradas +2 more
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120924/310befac/attachment.pl>
Hello, Try diff(v) Hope this helps, Rui Barradas Em 24-09-2012 12:00, Hermann Norpois escreveu:
Hello, I have a vector (numeric) v-> c(a,b,c,d,e) and I want to create the vector n->c(b-a,c-b,d-c,e-d). How can I do that? Thank you Hermann [[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.
Hi I suppose you want diff(v) Regards Petr
-----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r- project.org] On Behalf Of Hermann Norpois Sent: Monday, September 24, 2012 1:01 PM To: r-help at r-project.org Subject: [R] serial subtraction within a vector Hello, I have a vector (numeric) v-> c(a,b,c,d,e) and I want to create the vector n->c(b-a,c-b,d-c,e-d). How can I do that? Thank you Hermann [[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.
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:
Hello, I have a vector (numeric) v-> c(a,b,c,d,e) and I want to create the vector n->c(b-a,c-b,d-c,e-d). How can I do that? Thank you Hermann ? ? ? ? [[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.
??? [[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.