Dear All, please help with the following problem: I have t <-seq(0,24,by=6) a <-600 g <-0.05 b <-a*exp(-g*t) I would like to establish a vector called z (for example) based on b where the results are calculated as : z <-c(a-b[1],b[1]-b[2],b[2]-b[3],b[3]-b[4],b[4]-b[5]) so the results are: [1] 0.00000 155.50907 115.20395 85.34519 63.22527 as always your input is appreciated Andras [[alternative HTML version deleted]]
Homework? A hint is: ?diff Pat On 27/10/2013 11:37, Andras Farkas wrote:> Dear All, > > please help with the following problem: > > I have > > > t <-seq(0,24,by=6) > a <-600 > g <-0.05 > b <-a*exp(-g*t) > > I would like to establish a vector called z (for example) based on b where the results are calculated as : > > z <-c(a-b[1],b[1]-b[2],b[2]-b[3],b[3]-b[4],b[4]-b[5]) > > so the results are: > > [1] 0.00000 155.50907 115.20395 85.34519 63.22527 > > > as always your input is appreciated > > Andras > [[alternative HTML version deleted]] > > > > ______________________________________________ > R-help at r-project.org mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Patrick Burns pburns at pburns.seanet.com twitter: @burnsstat @portfolioprobe portfolioprobe.com/blog burns-stat.com (home of: 'Impatient R' 'The R Inferno' 'Tao Te Programming')