Take a look at diff() though offhand I dont know what it does to matrices M
On Oct 9, 2011, at 11:00 AM, Alaios <ala...@yahoo.com> wrote: > Dear all, > I have a matrix with data and I want to substract from every value the > previous element. > > Let's assume that my vector(matrix) is c<-(1,2,3,4,5) > I want to get remove_previous c<-(0,1,2,3,4). > > How I can do that efficiently in R? > > I would like to thank you in advance for your help > B.R > Alex > > [[alternative HTML version deleted]] > > ______________________________________________ > 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.