[R] apply question

Patrick Burns pburns at pburns.seanet.com
Sun Oct 27 12:51:39 CET 2013


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

-- 
Patrick Burns
pburns at pburns.seanet.com
twitter: @burnsstat @portfolioprobe
http://www.portfolioprobe.com/blog
http://www.burns-stat.com
(home of:
  'Impatient R'
  'The R Inferno'
  'Tao Te Programming')



More information about the R-help mailing list